# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29294 | 2017-07-19T01:39:22 Z | 시제연(#1167) | Meteors (POI11_met) | C++11 | 2153 ms | 63516 KB |
#include <bits/stdc++.h> #define s first #define e second using namespace std; typedef long long ll; typedef pair<int,int> pii; int n, m, k; struct query { int l, r; ll a; query(){} query(int l, int r, ll a):l(l),r(r),a(a){} }; struct idxtree { ll tree[1050000]; int key = 524288; void init() { for (int i=0;i<key*2;i++) tree[i] = 0; } void updr(int s, int e, ll val) { s+=key;e+=key; while(s<=e) { if (s&1) tree[s] += val; if (~e&1) tree[e] += val; s = (s+1)>>1; e = (e-1)>>1; } } ll getv(int idx) { ll res = 0; idx += key; while(idx>0) { res += tree[idx]; idx>>=1; } return res; } void upd(int s, int e, ll val) { if (s<=e) updr(s,e,val); else { updr(s,m-1,val); updr(0,e,val); } } } it; int own[300100]; vector<int> lis[300100]; ll p[300100]; query arr[300100]; vector<int> loc[300100]; vector<int> tmp[300100]; pii yan[300100]; int res[300100]; void init(int s, int e) { if (s>e) return; int m = (s+e)>>1; yan[m] = pii(s,e); init(s,m-1); init(m+1,e); } void pb() { int i; for (i=0;i<n;i++) tmp[k/2].push_back(i); init(0,k); while(true) { for (i=0;i<=k;i++) { loc[i].assign(tmp[i].begin(),tmp[i].end()); tmp[i].clear(); } bool flag = 1; it.init(); for (i=0;i<=k;i++) { for (int v : loc[i]) { flag = 0; ll sum = 0; for (int l : lis[v]) sum += it.getv(l); if (sum>=p[v]) { if (i==yan[i].s) res[v] = i; else tmp[(yan[i].s+i-1)/2].push_back(v); } else { if (i==yan[i].e) res[v] = i+1; else tmp[(yan[i].e+i+1)/2].push_back(v); } } if (i==k) break; it.upd(arr[i].l,arr[i].r,arr[i].a); } if (flag) break; } } int main() { int i; scanf("%d%d",&n,&m); for (i=0;i<m;i++) { scanf("%d",&own[i]); own[i]--; lis[own[i]].push_back(i); } for (i=0;i<n;i++) scanf("%lld",&p[i]); scanf("%d",&k); for (i=0;i<k;i++) { int l, r; ll a; scanf("%d%d%lld",&l,&r,&a); l--; r--; arr[i] = query(l,r,a); } pb(); for (i=0;i<n;i++) { if (res[i]>=k+1) printf("NIE\n"); else printf("%d\n",res[i]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 43048 KB | Output is correct |
2 | Correct | 16 ms | 43180 KB | Output is correct |
3 | Correct | 13 ms | 43180 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 43048 KB | Output is correct |
2 | Correct | 13 ms | 43048 KB | Output is correct |
3 | Correct | 16 ms | 43180 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 196 ms | 44172 KB | Output is correct |
2 | Correct | 296 ms | 47584 KB | Output is correct |
3 | Correct | 243 ms | 46764 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 236 ms | 45836 KB | Output is correct |
2 | Correct | 256 ms | 45852 KB | Output is correct |
3 | Correct | 293 ms | 47452 KB | Output is correct |
4 | Correct | 66 ms | 45592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 149 ms | 44904 KB | Output is correct |
2 | Correct | 206 ms | 48352 KB | Output is correct |
3 | Correct | 139 ms | 43312 KB | Output is correct |
4 | Correct | 269 ms | 47320 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 236 ms | 43472 KB | Output is correct |
2 | Correct | 243 ms | 45988 KB | Output is correct |
3 | Correct | 203 ms | 43972 KB | Output is correct |
4 | Correct | 253 ms | 49244 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2153 ms | 63516 KB | Output is correct |
2 | Incorrect | 853 ms | 45700 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2139 ms | 61852 KB | Output is correct |
2 | Incorrect | 816 ms | 45184 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |