有没有dalao帮忙看一下怎么错的

P1478 陶陶摘苹果(升级版)

``` if(a+b>=n&&s>c[i].yi) ``` 改为 ``` if(a+b>=c[i].xi&&s>c[i].yi) ```
by huang_yue @ 2019-08-22 15:33:16


不对,是改为 ``` if(a+b>=c[i].xi&&s>=c[i].yi) ```
by huang_yue @ 2019-08-22 15:33:40


```cpp #include<bits/stdc++.h> using namespace std; struct tao { int xi; int yi; }c[5100]; bool cmp(tao a,tao b) { return a.yi<b.yi; } int main() {int n,a,s,b,sum=0; cin>>n>>s>>a>>b; for(int i=1;i<=n;i++) { cin>>c[i].xi; cin>>c[i].yi; } sort(c+1,c+n+1,cmp); for(int i=1;i<=n;i++) { if(a+b>=c[i].xi&&s>=c[i].yi) { sum++; s-=c[i].yi; } } cout<<sum; return 0; } ```
by zmx200767 @ 2019-08-22 16:31:01


[我做的AC题解](https://www.luogu.org/blog/are/yi-pian-jian-dan-di-tao-tao-zhai-peng-guo-sheng-ji-ban-ti-xie)
by chenpengda @ 2019-08-24 14:13:33


|