fork(1) download
  1. #include<iostream>
  2. using namespace std;
  3. long long x[10000], n, q;
  4. int main() {
  5. cin >> n >> q; if (n > 100 || q > 100)return 0; x[0] = 2000000000000;
  6. for (int i = 0; i < q; i++) {
  7. long long a, b, t = 0;
  8. cin >> a >> b;
  9. bool flag = false;
  10. for (int j = a; j >= 1; j--) {
  11. t += (x[j - 1] - x[j])*(a - j + 1);
  12. if (t >= b) {
  13. t -= (x[j - 1] - x[j])*(a - j + 1);
  14. for (int k = j + 1; k <= a; k++)x[k] = x[j];
  15. long long u = b - t;
  16. long long v1 = u / (a - j + 1), v2 = u % (a - j + 1);
  17. for (int k = j; k < j + v2; k++)x[k] += (v1 + 1);
  18. for (int k = j + v2; k <= a; k++)x[k] += v1;
  19. flag = true;
  20. break;
  21. }
  22. }
  23. }
  24. for (int i = 1; i <= n; i++)cout << x[i] << endl;
  25. return 0;
  26. }
Success #stdin #stdout 0s 3540KB
stdin
6 6
1 1
2 1
3 1
4 1
5 1
6 1
stdout
1
1
1
1
1
1