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

相关推荐

11-30 11:07
河南大学 Java
宇宙厂 测开 n*15
丘丘给个offer:有后选后
点赞 评论 收藏
分享
贪食滴🐶:你说熟悉扣篮的底层原理,有过隔扣职业球员的实战经验吗
点赞 评论 收藏
分享
牛客网
牛客企业服务