# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
202982 | 2020-02-18T20:50:52 Z | MKopchev | Meteors (POI11_met) | C++14 | 1521 ms | 39720 KB |
#include<bits/stdc++.h> using namespace std; const int nmax=3e5+42; int states; int n,inp[nmax]; vector<int> seen[nmax]; int want[nmax]; int samples; struct sample { int l,r,add; }; sample all[nmax]; int output[nmax]; long long fenwick[nmax]; void update(int pos,int add) { while(pos<=n) { fenwick[pos]+=add; pos=pos+(pos&(-pos)); } } void on(int l,int r,int add) { update(l,add); update(r+1,-add); } void note(int id,int mult) { int add=mult*all[id].add; if(all[id].l<=all[id].r)on(all[id].l,all[id].r,add); else {on(1,all[id].r,add);on(all[id].l,n,add);} } long long query(int pos) { long long ret=0; while(pos) { ret=ret+fenwick[pos]; pos=pos-(pos&(-pos)); } return ret; } bool proper(int id) { long long now=0; for(auto k:seen[id]) { now=now+query(k); if(now>=want[id])return 1; } return 0; } void solve(vector<int> active,int l,int r) { if(l>r)return; //everything in [1, l-1] is added /* cout<<l<<" "<<r<<" "<<(l+r)/2<<endl; cout<<"query: "; for(int i=1;i<=n;i++) cout<<query(i)<<" ";cout<<endl; */ int av=(l+r)/2; for(int i=l;i<=av;i++) note(i,1); vector<int> satisfied={},unsatisfied={}; for(auto k:active) { if(proper(k)){satisfied.push_back(k);output[k]=av;} else unsatisfied.push_back(k); } solve(unsatisfied,av+1,r); for(int i=l;i<=av;i++) note(i,-1); solve(satisfied,l,av-1); } int main() { scanf("%i%i",&states,&n); for(int i=1;i<=n;i++) { scanf("%i",&inp[i]); seen[inp[i]].push_back(i); } for(int i=1;i<=states;i++)scanf("%i",&want[i]); scanf("%i",&samples); for(int i=1;i<=samples;i++) scanf("%i%i%i",&all[i].l,&all[i].r,&all[i].add); for(int i=1;i<=states;i++)output[i]=samples+1; vector<int> active={}; for(int i=1;i<=states;i++)active.push_back(i); solve(active,1,samples); for(int i=1;i<=states;i++) if(output[i]>samples)printf("NIE\n"); else printf("%i\n",output[i]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 7416 KB | Output is correct |
2 | Correct | 11 ms | 7544 KB | Output is correct |
3 | Correct | 12 ms | 7416 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 7420 KB | Output is correct |
2 | Correct | 10 ms | 7544 KB | Output is correct |
3 | Correct | 11 ms | 7544 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 72 ms | 9592 KB | Output is correct |
2 | Correct | 121 ms | 12908 KB | Output is correct |
3 | Correct | 105 ms | 9720 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 104 ms | 9336 KB | Output is correct |
2 | Correct | 109 ms | 9512 KB | Output is correct |
3 | Correct | 128 ms | 11576 KB | Output is correct |
4 | Correct | 40 ms | 9976 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 9336 KB | Output is correct |
2 | Correct | 101 ms | 12024 KB | Output is correct |
3 | Correct | 55 ms | 8188 KB | Output is correct |
4 | Correct | 106 ms | 9976 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 97 ms | 8824 KB | Output is correct |
2 | Correct | 106 ms | 9592 KB | Output is correct |
3 | Correct | 86 ms | 9208 KB | Output is correct |
4 | Correct | 127 ms | 11132 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1064 ms | 29008 KB | Output is correct |
2 | Correct | 628 ms | 15844 KB | Output is correct |
3 | Correct | 261 ms | 12664 KB | Output is correct |
4 | Correct | 1369 ms | 34800 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1016 ms | 25656 KB | Output is correct |
2 | Correct | 699 ms | 15984 KB | Output is correct |
3 | Correct | 223 ms | 13304 KB | Output is correct |
4 | Correct | 1521 ms | 39720 KB | Output is correct |