# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
762341 |
2023-06-21T10:28:35 Z |
vjudge1 |
Meteors (POI11_met) |
C++17 |
|
2681 ms |
46960 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
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];
int t[N*4] , l[N] , r[N] , c[N];
vector<int> g[N] , q[N] , q1[N];
void build(int v , int tl , int tr){
t[v] = 0;
if(tl == tr) return;
int tm = (tl+tr) >> 1;
build(v*2,tl,tm);
build(v*2+1,tm+1,tr);
}
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);
}
int 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];
int ok = 1;
while(ok){
ok = 0;
build(1,1,m);
for(int i = 1; i <= k; i++){
if(l[i] > r[i]){
upd(1,1,m,l[i],m,c[i]);
upd(1,1,m,1,r[i],c[i]);
} else {
upd(1,1,m,l[i],r[i],c[i]);
}
for(int x : q[i]){
int sum = p[x];
for(int y : g[x]) sum -= get(1,1,m,y);
if(sum <= 0){
res[x] = i;
R[x] = i-1;
} else {
L[x] = i+1;
}
if(L[x] <= R[x]){
q1[(L[x]+R[x])/2].push_back(x);
ok++;
}
}
q[i].clear();
}
swap(q,q1);
}
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 |
21 ms |
21452 KB |
Output is correct |
2 |
Correct |
23 ms |
21596 KB |
Output is correct |
3 |
Correct |
20 ms |
21480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
21580 KB |
Output is correct |
2 |
Correct |
21 ms |
21476 KB |
Output is correct |
3 |
Correct |
20 ms |
21612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
260 ms |
24268 KB |
Output is correct |
2 |
Correct |
311 ms |
26584 KB |
Output is correct |
3 |
Correct |
315 ms |
26060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
282 ms |
25516 KB |
Output is correct |
2 |
Correct |
297 ms |
25576 KB |
Output is correct |
3 |
Correct |
316 ms |
26796 KB |
Output is correct |
4 |
Correct |
82 ms |
24268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
166 ms |
24664 KB |
Output is correct |
2 |
Correct |
218 ms |
27360 KB |
Output is correct |
3 |
Correct |
140 ms |
22692 KB |
Output is correct |
4 |
Correct |
296 ms |
26544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
280 ms |
23928 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2681 ms |
46960 KB |
Output is correct |
2 |
Incorrect |
1356 ms |
34644 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2626 ms |
45784 KB |
Output is correct |
2 |
Incorrect |
976 ms |
34644 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |