Submission #748584

#TimeUsernameProblemLanguageResultExecution timeMemory
748584penguin133Meteors (POI11_met)C++17
74 / 100
1185 ms31252 KiB
#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<25;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 <= m; 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 (stderr)

met.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   67 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...