求大佬调
查看原帖
求大佬调
1586975
coldstarlight楼主2025/7/3 15:13
#include<bits/stdc++.h>
using namespace std;
int star, fue, ans=0, cnt=0, stars = 0;
struct dy {
	int b;
	int c;
}a[1000010];
int cmp (dy x, dy y) {
	return x.b < y.b;
}
int main () {
	cin >> star >> fue;
	for (int i = 1; i <= star; i++) {
		int st1, st2;cin>>st1>>st2;
		if (st1-st2>=0&&i!=star) {
			a[++cnt].b=st2;
			a[cnt].c=st1-st2;
		}
		if (i==fue) ans = st1;
	}
	sort(a+1, a+star+1, cmp);
	for (int i = 1; i <= cnt; i++) {
		if (ans >= a[i].b) {
			ans+=a[i].c;
			stars++;	
		}else break;
	}
	cout << ans << endl << stars;
	return 0;	
}

求大佬调代码求大佬调代码

说明一下为什么不对

Please帮帮忙吧QAQPlease 帮帮忙吧 QAQ

2025/7/3 15:13
加载中...