Submission #477746

#TimeUsernameProblemLanguageResultExecution timeMemory
477746mat_vMeteors (POI11_met)C++14
74 / 100
1095 ms38212 KiB
#include <bits/stdc++.h> #define pb push_back #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i)) using namespace std; typedef long long ll; int n,m,q; int niz[300005]; vector<int> drz[300005]; ll targ[300005]; int le[300005]; int ri[300005]; ll val[300005]; vector<int> buc[300005]; int l[300005]; int r[300005]; int bucs[300005]; int ans[300005]; ll bit[400005]; void upd(int x, ll val){ while(x <= n){ bit[x] += val; x += (x&-x); } } ll kveri(int x){ ll res = 0; while(x > 0){ res += bit[x]; x -= (x&-x); } return res; } int main() { ios_base::sync_with_stdio(false); cin >> m >> n; ff(i,1,n){ cin >> niz[i]; drz[niz[i]].pb(i); } ff(i,1,m)cin >> targ[i]; cin >> q; ff(i,1,q)cin >> le[i] >> ri[i] >> val[i]; ff(i,1,m){ l[i] = 1; r[i] = q; bucs[i] = (1+q)/2; ans[i] = -1; } while(1){ bool ch = 0; fill(bit, bit + 400000, 0LL); ff(i,1,q)buc[i].clear(); ff(i,1,m){ if(l[i] <= r[i]){ ch = 1; buc[(l[i] + r[i]) / 2].pb(i); } } if(!ch)break; ff(i,1,q){ if(le[i] > ri[i]){ upd(le[i], val[i]); upd(1, val[i]); upd(ri[i] + 1, -val[i]); } else{ upd(le[i], val[i]); upd(ri[i] + 1, -val[i]); } for(auto c:buc[i]){ ll sm = 0; for(auto tt:drz[c])sm += kveri(tt); if(sm >= targ[c]){ ans[c] = i; r[c] = i-1; } else l[c] = i+1; } } } ff(i,1,m){ if(ans[i] == -1 || ans[i] > q)cout << "NIE\n"; else cout << ans[i] << "\n"; } return 0; }

Compilation message (stderr)

met.cpp: In function 'int main()':
met.cpp:3:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    3 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
met.cpp:43:5: note: in expansion of macro 'ff'
   43 |     ff(i,1,n){
      |     ^~
met.cpp:3:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    3 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
met.cpp:47:5: note: in expansion of macro 'ff'
   47 |     ff(i,1,m)cin >> targ[i];
      |     ^~
met.cpp:3:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    3 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
met.cpp:49:5: note: in expansion of macro 'ff'
   49 |     ff(i,1,q)cin >> le[i] >> ri[i] >> val[i];
      |     ^~
met.cpp:3:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    3 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
met.cpp:50:5: note: in expansion of macro 'ff'
   50 |     ff(i,1,m){
      |     ^~
met.cpp:3:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    3 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
met.cpp:59:9: note: in expansion of macro 'ff'
   59 |         ff(i,1,q)buc[i].clear();
      |         ^~
met.cpp:3:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    3 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
met.cpp:60:9: note: in expansion of macro 'ff'
   60 |         ff(i,1,m){
      |         ^~
met.cpp:3:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    3 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
met.cpp:67:9: note: in expansion of macro 'ff'
   67 |         ff(i,1,q){
      |         ^~
met.cpp:3:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    3 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
met.cpp:88:5: note: in expansion of macro 'ff'
   88 |     ff(i,1,m){
      |     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...