fork download
  1. // Author: 4uckd3v - Nguyen Cao Duc
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. #define all(x) (x).begin(), (x).end()
  6.  
  7. typedef long long ll;
  8.  
  9. const int MAX_N = 1e5;
  10. const int MOD = 1e9 + 7;
  11.  
  12. struct FenwickTree {
  13. vector<pair<int, ll>> bit;
  14. int n;
  15.  
  16. void update(int pos, ll val) {
  17. for (; pos <= n; pos += pos & (-pos))
  18. bit[pos].first++, bit[pos].second += val;
  19. };
  20.  
  21. pair<int, ll> get(int pos) {
  22. pair<int, ll> ret = make_pair(0, 0);
  23. for (; pos > 0; pos -= pos & (-pos))
  24. ret.first += bit[pos].first, ret.second += bit[pos].second;
  25. return ret;
  26. };
  27.  
  28. FenwickTree(int n) : n(n) {
  29. bit.assign(n + 5, make_pair(0, 0));
  30. };
  31. };
  32.  
  33. int n, m, k;
  34. int d[MAX_N + 5], pref[MAX_N + 5], h[MAX_N + 5], t[MAX_N + 5];
  35. vector<int> compress;
  36.  
  37. int getIndex(const vector<int>& v, int x) {
  38. return lower_bound(all(compress), x) - compress.begin() + 1;
  39. };
  40.  
  41. int main() {
  42. ios_base::sync_with_stdio(0);
  43. cin.tie(0);
  44. if (fopen("MAIN.INP", "r")) {
  45. freopen("MAIN.INP", "r", stdin);
  46. freopen("MAIN.OUT", "w", stdout);
  47. };
  48.  
  49. cin >> n >> m >> k;
  50. for (int i = 2; i <= n; i++) {
  51. cin >> d[i];
  52. pref[i] = pref[i - 1] + d[i];
  53. };
  54.  
  55. for (int i = 1; i <= m; i++) {
  56. cin >> h[i] >> t[i];
  57. compress.push_back(t[i]);
  58. compress.push_back(t[i] - pref[h[i]]);
  59. };
  60. compress.push_back(0);
  61.  
  62. sort(all(compress));
  63. compress.resize(unique(all(compress)) - compress.begin());
  64.  
  65. for (int i = 1; i <= n; i++) {
  66. };
  67. };
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty