0
已解决
张元宝
修练者
修练者
# include<bits/stdc++.h> using namespace std; struct apple{ int hight; int power; }a[10000]; bool cmp(apple x,apple y){ return x.power<y.power; } int main(){ int h,l; int n,high,k=0; cin>>h>>l; cin>>n>>high; for(int i=1;i<=n;i++) cin>>a[i].hight; for(int i=1;i<=n;i++) cin>>a[i].power; high+=h; sort(a+1,a+1+n,cmp); for(int i=1;i<=n;i++){ if(a[i].hight<high&&l>=0){ k++; l-=a[i].power; // cout<<a[i].hight<<" "<<a[i].power<<endl; } if(l-a[i].power<0){ break; } } cout<<k; return 0; }为何!!!!