AC存疑!!!
查看原帖
AC存疑!!!
1554563
bjcakioi楼主2025/2/7 20:40
#include<bits/stdc++.h>
using namespace std;
#define int long long 
struct apple{
	int height,strength;
}a[10050];
struct able{
	int h,s;
}b[10050];
bool cmp(able x,able y){
	return x.s<y.s;
}
int n,totalstrength,chair,taotao,uke=1,ans=0,p=2,used=0;
signed main(){
	cin>>n>>totalstrength>>chair>>taotao;
	for(int i=1;i<=n;i++){
		cin>>a[i].height>>a[i].strength;
	}
	for(int i=1;i<=n;i++){
		if(a[i].height<=chair+taotao){
			b[uke].h=a[i].height;
			b[uke++].s=a[i].strength;
		}
	}
	sort(b+1,b+uke+1,cmp);
	while(used<=totalstrength&&used+b[p+1].s<=totalstrength){
		used+=b[p].s;
		p++;
		ans++;
	}
	
	cout<<ans; 
	return 0;
}//while循环里写小于等于为什么会RE第四个点?但只有第二个表达式写不会,但只有一个循环终止条件的表达式是小于等于或者两个循环终止条件都是小于等于会RE???求大佬解答!闭关!!!
2025/2/7 20:40
加载中...