fork download
  1. #include<iostream>
  2. #include<queue>
  3. using namespace std;
  4. int main() {
  5. int n; cin >> n;
  6. int t = 0;
  7. for (int i = 0; i < 6; i++) {
  8. int x; cin >> x;
  9. t += x;
  10. }
  11. priority_queue<pair<int, int>, vector<pair<int, int>>>pp;
  12. vector<priority_queue<int>>vp(n);
  13. for (int i = 0; i < n; i++) {
  14. int tt = 0;
  15. int x = 0;
  16. for (int j = 0; j < 6; j++) {
  17. cin >> x;
  18. tt += x;
  19. vp[i].push(x);
  20. }
  21. pp.push({ tt , i });
  22. }
  23. int cnt = 0;
  24. while (t <= pp.top().first) {
  25. t += 100;
  26. int tt = pp.top().first;
  27. int id = pp.top().second;
  28. tt -= vp[id].top();
  29. vp[id].pop();
  30. pp.pop();
  31. pp.push({ tt,id });
  32. cnt++;
  33. }
  34. while(!pp.empty()){cout<<pp.top().first<<endl;pp.pop();}
  35. cout << cnt;
  36. }
Success #stdin #stdout 0.01s 5480KB
stdin
4
1100 0 0 0 0 0
1200 400 100 0 0 0
1100 400 100 0 0 0
1000 300 100 0 0 0
900  400 200 0 0 0
stdout
600
500
500
400
4