大佬求助

P1478 陶陶摘苹果(升级版)

MikaMizuho @ 2018-07-19 14:58:45

include<bits/stdc++.h>

using namespace std; struct x{ double height,power; }y[5001]; int main() { int n,s,a,b; cin>>n>>s>>a>>b; for(int i=1;i<=n;i++) { cin>>y[i].height>>y[i].power; if(y[i].height>a+b) { y[i].height=0; y[i].power=101; } } for(int j=n-1;j>0;j--) { for(int k=0;k<j;k++) { if(y[k].power>y[k+1].power) { swap(y[k],y[k+1]); } } } double sum=0; int c=0; for(int i=0;i<=n;i++) { sum+=y[i].power; if(sum<=y[i].power) c++; } cout<<c; return 0; }


by AsTolling @ 2018-07-19 15:00:46

点击</>发代码 hua|ji


by MikaMizuho @ 2018-07-19 15:18:16

已解决,谢谢


|