제출 #1129273

#제출 시각아이디문제언어결과실행 시간메모리
1129273KN200711새로운 문제 (POI11_met)C++20
74 / 100
757 ms35808 KiB
# include <bits/stdc++.h> # define ll long long # define ld long double # define fi first # define se second # define pii pair<int, int> using namespace std; int N, M, Q; ll fen[300001]; void add(int a, ll ad) { while(a > 0) { fen[a] += ad; a -= a&(-a); } } ll qr(int a) { ll as = 0ll; while(a <= M) { as += fen[a]; a += a&(-a); } return as; } vector<int> pl[300001]; ll target[300001]; int L[300001], R[300001], ans[300001]; vector< pair<pii, ll> > qry; vector<int> ask[300001]; int main() { scanf("%d %d", &N, &M); for(int i=1;i<=M;i++) { int a; scanf("%d", &a); pl[a].push_back(i); } for(int i=1;i<=N;i++) { scanf("%lld", &target[i]); } int Q; scanf("%d", &Q); for(int i=0;i<Q;i++) { int l, r; ll val; scanf("%d %d %lld", &l, &r, &val); qry.push_back({{l, r}, val}); } for(int i=1;i<=N;i++) { L[i] = 0, R[i] = Q-1, ans[i] = -1; } for(int i=0;i<21;i++) { for(int k=0;k<=M;k++) fen[k] = 0ll; for(int k=0;k<Q;k++) ask[k].clear(); for(int k=1;k<=N;k++) { if(L[k] <= R[k]) { int mid = (L[k] + R[k]) / 2; ask[mid].push_back(k); } } for(int k=0;k<Q;k++) { int l = qry[k].fi.fi, r = qry[k].fi.se; ll val = qry[k].se; if(l <= r) { add(r, val); add(l - 1, -val); } else { add(M, val); add(l - 1, -val); add(r, val); add(0, -val); } for(auto p : ask[k]) { ll cek = 0ll; for(auto c : pl[p]) cek += qr(c); if(cek >= target[p]) { ans[p] = k; R[p] = k - 1; } else L[p] = k + 1; // cout<<"p, k : "<<p<<" "<<k<<" "<<cek<<endl; } } } for(int k=1;k<=N;k++) { if(ans[k] == -1) printf("NIE\n"); else printf("%d\n", ans[k] + 1); } }

컴파일 시 표준 에러 (stderr) 메시지

met.cpp: In function 'int main()':
met.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d %d", &N, &M);
      |         ~~~~~^~~~~~~~~~~~~~~~~
met.cpp:39:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |                 scanf("%d", &a);
      |                 ~~~~~^~~~~~~~~~
met.cpp:44:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |                 scanf("%lld", &target[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~
met.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         scanf("%d", &Q);
      |         ~~~~~^~~~~~~~~~
met.cpp:52:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |                 scanf("%d %d %lld", &l, &r, &val);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...