AC代码: void CountNumbers() { int n; cin >> n; vector<long long>ones = { 11, 111}; vector<long long >nums(n); int cnt = 0; for (int i = 0; i < n; ++i) { cin >> nums[i]; if (nums[i] % 11 == 0 || nums[i] % 111 == 0) { cnt++; continue; } long long b = nums[i] % 11; int mul = b; while (true) { if (nums[i] - 111 * mul > 0) { if ((nums[i] - 111 * mul) % 11 == 0) { cnt++; break; } mul += 11; } else break; } } cout << cnt << endl; } void maxCountGoods() { int n; cin >> n; vector<long long>happy_value(n); for (int i = 0; i < n; ++i) { cin >> happy_value[i]; } priority_queue<long long,vector<long long>, greater<long long> >qu; long long now = 0, cnt = 0; for (int i = 0; i < n; ++i) { now += happy_value[i]; cnt++; if (happy_value[i] < 0) qu.push(happy_value[i]); while(now < 0 && !qu.empty()) { now -= qu.top(); qu.pop(); cnt--; } } cout << cnt << endl; }
点赞 9

相关推荐

点赞 评论 收藏
分享
05-20 13:59
门头沟学院 Java
米黑子米黑子:你这个成绩不争取下保研?
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-01 17:13
想去,但是听说加班强度实在难崩,所以拒绝了,现在有点心梗对面hr感觉也是实习生,打电话的时候怪紧张的,但是感觉人很好嘞
水中水之下水道的鼠鼠:哥们这不先去体验一下,不行再跑呗,大不了混个实习经历(有更好的转正offer就当我没说)
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务