B题不用结构体的解法 #include<iostream> (30316)#include<string> #include<cstring> (31637)#include<vector> #include<map> (30192)#include<set> #include<queue> (30193)#include<cmath> #include<cstdio> (31159)#include<algorithm> #define int long long using namespace std; const int N = 1e6 + 5; const int inf = 0x3f3f3f3f;//106110956 int a[N], b[N], c[N]; void solve() { int x, n, m; cin >> x >> n >> m; int cnt = 0; for(int i = 1; i <= n; i++){ cin >> a[i] >> b[i]; if(a[i] <= m){ c[cnt++] = b[i]; } } sort(c, c + cnt); int ans = x, res = 0; for(int i = 0; i < cnt; i++){ int t = ans; if(t - c[i] > 0){ res++; } ans -= c[i]; } cout << res << endl; } signed main() { ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); int t = 1; //cin >> t; while(t--){ solve(); } return 0; }

相关推荐

这个简历还有救吗,考研失利了,完蛋蛋了
飞屋一号:放宽心,9爷就业还是轻轻松松的
点赞 评论 收藏
分享
02-26 09:15
已编辑
蚌埠学院 golang
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务