稻花香里说丰年,听取WA,RE片
查看原帖
稻花香里说丰年,听取WA,RE片
1142251
wei345楼主2024/10/15 18:50

测试点信息 4ms/564.00KB AC #1 Accepted, 得分 20.ok accepted 3ms/556.00KB AC #2 Accepted, 得分 20.ok accepted 4ms/564.00KB WA #3 Wrong Answer.wrong answer On line 1 column 1, read 1, expected 9. 3ms/564.00KB AC #4 Accepted, 得分 20.ok accepted 0ms/0B RE #5 Runtime Error. Received signal 11: Segmentation fault with invalid memory reference.

#include<bits/stdc++.h>
using namespace std;
struct ns{
	int x,y;
}q[1001];
bool cmp(ns z,ns z1){
	return z.x>z1.x;
}
int n,a,s,x[1001],b,y[1011],ans;
int main(){	
	std::cin>>n>>s>>a>>b;
	for(int i=1;i<=n;i++){
		cin>>q[i].x>>q[i].y;
	}
	sort(q+1,q+n+1,cmp);
	for(int i=1;i<=n;i++){
		if(q[i].x<=a+b&&q[i].y<=s){
			s-=q[i].y;
			ans++;
		}
	}
	cout<<ans;
	return 0;
}
2024/10/15 18:50
加载中...