# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
448561 |
2021-07-30T17:42:23 Z |
qwerasdfzxcl |
Meteors (POI11_met) |
C++17 |
|
2799 ms |
65540 KB |
#include <bits/stdc++.h>
#define ll __int128_t
#define int long long
using namespace std;
struct Seg{
ll tree[600600];
int sz;
void init(){
for (int i=1;i<((sz)<<1);i++) tree[i] = 0;
}
void update_p(int i, int p){
i += sz;
for (tree[i]+=p;i>1;i>>=1) tree[i>>1] = tree[i]+tree[i^1];
}
void update(int l, int r, int p){
update_p(l, p);
if (r<sz-1) update_p(r+1, -p);
}
ll query(int l, int r){
ll ret = 0;
for (l += sz, r += sz;l<r;l>>=1, r>>=1){
if (l&1) ret += tree[l++];
if (r&1) ret += tree[--r];
}
return ret;
}
}tree;
struct Query{
int l, r, a;
}query[300300];
vector<int> ar[300300], q[300300];
int l[300300], r[300300], ans[300300];
int val[300300];
signed main(){
int n, m;
cin.tie(NULL);
ios_base::sync_with_stdio(false);
cin >> n >> m;
tree.sz = m+1;
for (int i=1;i<=m;i++){
int x;
cin >> x;
ar[x-1].push_back(i);
}
for (int i=0;i<n;i++) cin >> val[i];
int tmp;
cin >> tmp;
for (int i=0;i<tmp;i++){
cin >> query[i].l >> query[i].r >> query[i].a;
}
for (int i=0;i<n;i++) l[i] = 0, r[i] = tmp;
while(1){
//assert(c<12);
bool chk=0;
for (int i=0;i<=tmp;i++) q[i].clear();
for (int i=0;i<n;i++) if (l[i]!=r[i]){
q[(l[i]+r[i])>>1].push_back(i);
chk=1;
}
if (!chk) break;
tree.init();
for (int i=0;i<tmp;i++){
if (query[i].l<=query[i].r) tree.update(query[i].l, query[i].r, query[i].a);
else{
tree.update(1, query[i].r, query[i].a);
tree.update(query[i].l, m, query[i].a);
}
for (auto &j:q[i]){
ll tmp1 = 0;
for (auto &x:ar[j]){
tmp1 += tree.query(1, x+1);
}
if (tmp1>=val[j]){
r[j] = i;
ans[j] = i+1;
}
else l[j] = i+1;
}
//tree.debug();
}
}
for (int i=0;i<n;i++){
if (l[i] == tmp) cout << "NIE\n";
else cout << ans[i] << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14548 KB |
Output is correct |
2 |
Correct |
10 ms |
14492 KB |
Output is correct |
3 |
Correct |
10 ms |
14540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
14572 KB |
Output is correct |
2 |
Correct |
10 ms |
14588 KB |
Output is correct |
3 |
Correct |
10 ms |
14580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
18648 KB |
Output is correct |
2 |
Correct |
225 ms |
21864 KB |
Output is correct |
3 |
Correct |
202 ms |
20856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
192 ms |
20188 KB |
Output is correct |
2 |
Correct |
195 ms |
20120 KB |
Output is correct |
3 |
Correct |
224 ms |
22392 KB |
Output is correct |
4 |
Correct |
73 ms |
19208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
129 ms |
19084 KB |
Output is correct |
2 |
Correct |
162 ms |
22492 KB |
Output is correct |
3 |
Correct |
58 ms |
15736 KB |
Output is correct |
4 |
Correct |
195 ms |
21544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
179 ms |
17768 KB |
Output is correct |
2 |
Correct |
178 ms |
20032 KB |
Output is correct |
3 |
Correct |
157 ms |
18244 KB |
Output is correct |
4 |
Correct |
236 ms |
23716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2778 ms |
55600 KB |
Output is correct |
2 |
Correct |
978 ms |
33484 KB |
Output is correct |
3 |
Correct |
274 ms |
20412 KB |
Output is correct |
4 |
Runtime error |
2097 ms |
65540 KB |
Execution killed with signal 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2799 ms |
53352 KB |
Output is correct |
2 |
Correct |
821 ms |
33480 KB |
Output is correct |
3 |
Correct |
233 ms |
19268 KB |
Output is correct |
4 |
Runtime error |
1492 ms |
65540 KB |
Execution killed with signal 9 |