# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
748581 |
2023-05-26T14:00:06 Z |
penguin133 |
Meteors (POI11_met) |
C++17 |
|
1100 ms |
39136 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int q, n, m;
pii Q[300005];
int A[300005], B[300005], ans[300005], L[300005], R[300005];
vector <int> grr[300005];
int ft[300005];
void upd(int l, int r, int v){
r++;
for(;l<=m;l+=(l & -l))ft[l] += v;
for(;r<=m;r+=(r & -r))ft[r] -= v;
}
int qry(int p){
int res = 0;
for(;p;p-=(p & -p))res += ft[p];
return res;
}
void solve(){
cin >> n >> m;
for(int i=1;i<=m;i++)cin >> B[i], grr[B[i]].push_back(i);
for(int i=1;i<=n;i++)cin >> A[i];
cin >> q;
for(int i=1;i<=q;i++)cin >> Q[i].fi >> Q[i].se.fi >> Q[i].se.se;
for(int i=1;i<=n;i++)ans[i] = q + 5, L[i] = 1, R[i] = q;
for(int i=0;i<20;i++){
vector <pi> ord;
for(int j = 1; j <= n; j++){
if(L[j] > R[j])continue;
int mid = (L[j] + R[j]) >> 1;
ord.push_back({mid, j});
}
sort(ord.begin(), ord.end());
for(int j = 1; j <= n; j++)ft[j] = 0;
int in = 0;
for(int j = 1; j <= q; j++){
if(Q[j].fi <= Q[j].se.fi)upd(Q[j].fi, Q[j].se.fi, Q[j].se.se);
else upd(Q[j].fi, m, Q[j].se.se), upd(1, Q[j].se.fi, Q[j].se.se);
while(in < (int)ord.size() && ord[in].fi == j){
int tmp = 0;
for(auto k : grr[ord[in].se])tmp += qry(k);
if(tmp >= A[ord[in].se])ans[ord[in].se] = j, R[ord[in].se] = j - 1;
else L[ord[in].se] = j + 1;
in++;
}
}
}
for(int i=1;i<=n;i++){
if(ans[i] <= q)cout << ans[i] << '\n';
else cout << "NIE\n";
}
}
main(){
ios::sync_with_stdio(0);cin.tie(0);
int tc = 1;
//cin >> tc;
for(int tc1=1;tc1<=tc;tc1++){
// cout << "Case #" << tc1 << ": ";
solve();
}
}
Compilation message
met.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
67 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
7508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
7508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
70 ms |
11204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
96 ms |
11848 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
84 ms |
11224 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
86 ms |
10832 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1100 ms |
39136 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1055 ms |
38024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |