# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
762372 |
2023-06-21T10:59:21 Z |
vjudge1 |
Meteors (POI11_met) |
C++17 |
|
206 ms |
65536 KB |
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
#define int ll
using namespace std;
using ll = long long;
const int N = 3e5+5 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7 , P = 6547;
int p[N] , n , m , k , L[N] , R[N] , res[N];
ll t[N*4];
int l[N] , r[N] , c[N];
vector<int> g[N] , q[N] , q1[N] , v;
void upd(int i, int x) {
for(; i <= m; i |= (i + 1)) t[i] += x , v.push_back(i);
}
void updlr(int l, int r, int x){
upd(l, x); upd(r + 1, -x);
}
ll get(int i){
ll res = 0;
for(; i > 0; i = (i & (i + 1)) - 1) res += t[i];
return res;
}
void cl(){
while(v.size()){
t[v.back()] = 0;
v.pop_back();
}
}
void upd(int v, int tl , int tr , int l , int r , int val){
if(l <= tl && tr <= r){
t[v] += val;
return;
}
if(tl > r || tr < l) return;
int tm = (tl+tr) >> 1;
upd(v*2,tl,tm,l,r,val);
upd(v*2+1,tm+1,tr,l,r,val);
}
ll get(int v, int tl , int tr , int pos){
if(tl == tr) return t[v];
int tm = (tl+tr) >> 1;
if(tm >= pos) return get(v*2,tl,tm,pos)+t[v];
else return get(v*2+1,tm+1,tr,pos)+t[v];
}
void solve(){
cin >> n >> m;
for(int i = 1; i <= m; i++) {
int a;
cin >> a;
g[a].push_back(i);
}
for(int i = 1; i <= n; i++) cin >> p[i];
cin >> k;
for(int i = 1; i <= n; i++) {
L[i] = 1;
R[i] = k;
q[(L[i]+R[i])/2].push_back(i);
}
for(int i = 1; i <= k; i++) cin >> l[i] >> r[i] >> c[i];
for(int _ = 1; _ <= 20; _++){
cl();
for(int i = 1; i <= k; i++){
if(l[i] > r[i]){
updlr(l[i],m,c[i]);
updlr(1,r[i],c[i]);
} else updlr(l[i],r[i],c[i]);
for(int x : q[i]){
ll sum = p[x];
for(int y : g[x]) sum -= get(y);
if(sum <= 0){
res[x] = i;
R[x] = i-1;
} else {
L[x] = i+1;
}
if(L[x] <= R[x]) q[(L[x]+R[x])/2].push_back(x);
}
q[i].clear();
}
}
for(int i = 1; i <= n; i++) {
if(res[i] == 0){
cout << "NIE\n";
} else {
cout << res[i] << "\n";
}
}
}
/*
*/
signed main(){
ios;
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
21716 KB |
Output is correct |
2 |
Correct |
11 ms |
21720 KB |
Output is correct |
3 |
Correct |
14 ms |
21756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
21760 KB |
Output is correct |
2 |
Correct |
12 ms |
21716 KB |
Output is correct |
3 |
Correct |
12 ms |
21852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
129 ms |
32088 KB |
Output is correct |
2 |
Correct |
202 ms |
42040 KB |
Output is correct |
3 |
Correct |
154 ms |
33876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
175 ms |
40764 KB |
Output is correct |
2 |
Correct |
184 ms |
40756 KB |
Output is correct |
3 |
Correct |
206 ms |
41812 KB |
Output is correct |
4 |
Correct |
36 ms |
25760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
40468 KB |
Output is correct |
2 |
Correct |
143 ms |
42024 KB |
Output is correct |
3 |
Correct |
80 ms |
31112 KB |
Output is correct |
4 |
Correct |
147 ms |
34632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
188 ms |
40288 KB |
Output is correct |
2 |
Correct |
182 ms |
40808 KB |
Output is correct |
3 |
Correct |
136 ms |
32180 KB |
Output is correct |
4 |
Correct |
188 ms |
41860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
131 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
136 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |