# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
497057 |
2021-12-22T09:13:10 Z |
Ierus |
Meteors (POI11_met) |
C++17 |
|
3791 ms |
65540 KB |
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define sz size()
#define pb push_back
#define int long long
#define all(x) (x).begin(),(x).end()
#define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
const int N = 3e5+1;
int n, m, que, t[N<<2];
void U(int l, int r, int val, int v, int tl, int tr){
if(tl > r || tr < l) return;
if(l <= tl && tr <= r){
t[v] += val;
return;
}
int tm = (tl + tr) >> 1;
U(l,r,val,v<<1,tl,tm);
U(l,r,val,v<<1|1,tm+1,tr);
}
int G(int pos, int v, int l, int r){
if(l == r) return t[v];
int m = (l + r) >> 1;
if(pos <= m) return G(pos,v<<1,l,m) + t[v];
else return G(pos,v<<1|1,m+1,r) + t[v];
}
vector<int> g[N], ans(N, -1), tocheck[N];;
int p[N], Q[N], L[N], R[N];
struct{int l, r, a;}q[N];
signed main(){
cin >> n >> m;
for(int i = 1; i <= m; ++i){
int x; cin >> x;
g[x].pb(i);
}
for(int i = 1; i <= n; ++i){
cin >> p[i];
}
cin >> que;
for(int i = 1; i <= que; ++i){
cin >> q[i].l >> q[i].r >> q[i].a;
}
for(int i = 1; i <= n; ++i){
L[i] = 1, R[i] = que+1;
}
bool ok = 1;
while(ok){
ok = false;
memset(t, 0, sizeof(t));
for(int i = 1; i <= n; ++i){
if(L[i] != R[i]){
tocheck[(L[i]+R[i])/2].pb(i);
}
}
for(int i = 1; i <= que; ++i){
if(q[i].l > q[i].r){
U(q[i].l, m, q[i].a, 1, 1, m);
U(1, q[i].r, q[i].a, 1, 1, m);
}else{
U(q[i].l, q[i].r, q[i].a, 1, 1, m);
}
while(!tocheck[i].empty()){
ok = true;
int id = tocheck[i].back();
tocheck[i].pop_back();
int sum = 0;
for(auto x : g[id]){
sum += G(x, 1, 1, m);
if(sum >= p[id]){
break;
}
}
if(sum >= p[id]){
ans[id] = i;
R[id] = i;
}else L[id] = i + 1;
}
}
}
for(int i = 1; i <= n; ++i){
if(L[i] > que) cout << "NIE\n";
else cout << ans[i] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
26188 KB |
Output is correct |
2 |
Correct |
24 ms |
26228 KB |
Output is correct |
3 |
Correct |
24 ms |
26188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
26152 KB |
Output is correct |
2 |
Correct |
24 ms |
26164 KB |
Output is correct |
3 |
Correct |
27 ms |
26316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
320 ms |
28892 KB |
Output is correct |
2 |
Correct |
478 ms |
32128 KB |
Output is correct |
3 |
Correct |
413 ms |
31236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
364 ms |
30156 KB |
Output is correct |
2 |
Correct |
408 ms |
30432 KB |
Output is correct |
3 |
Correct |
396 ms |
32640 KB |
Output is correct |
4 |
Correct |
121 ms |
29492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
205 ms |
29164 KB |
Output is correct |
2 |
Correct |
284 ms |
32732 KB |
Output is correct |
3 |
Correct |
191 ms |
27680 KB |
Output is correct |
4 |
Correct |
389 ms |
31828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
320 ms |
28104 KB |
Output is correct |
2 |
Correct |
353 ms |
30528 KB |
Output is correct |
3 |
Correct |
338 ms |
28612 KB |
Output is correct |
4 |
Correct |
410 ms |
33948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3791 ms |
57560 KB |
Output is correct |
2 |
Correct |
1333 ms |
36008 KB |
Output is correct |
3 |
Correct |
835 ms |
32364 KB |
Output is correct |
4 |
Runtime error |
2245 ms |
65540 KB |
Execution killed with signal 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3701 ms |
55156 KB |
Output is correct |
2 |
Correct |
1026 ms |
35812 KB |
Output is correct |
3 |
Correct |
760 ms |
31208 KB |
Output is correct |
4 |
Runtime error |
1982 ms |
65540 KB |
Execution killed with signal 9 |