結果
問題 | No.2942 Sigma Music Game Level Problem |
ユーザー | FplusFplusF |
提出日時 | 2024-10-18 21:57:30 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 375 ms / 6,000 ms |
コード長 | 2,599 bytes |
コンパイル時間 | 2,757 ms |
コンパイル使用メモリ | 249,708 KB |
実行使用メモリ | 14,248 KB |
最終ジャッジ日時 | 2024-10-18 22:43:27 |
合計ジャッジ時間 | 8,724 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
6,820 KB |
testcase_01 | AC | 6 ms
6,820 KB |
testcase_02 | AC | 5 ms
6,820 KB |
testcase_03 | AC | 5 ms
6,820 KB |
testcase_04 | AC | 7 ms
6,820 KB |
testcase_05 | AC | 6 ms
6,816 KB |
testcase_06 | AC | 5 ms
6,820 KB |
testcase_07 | AC | 5 ms
6,824 KB |
testcase_08 | AC | 5 ms
6,816 KB |
testcase_09 | AC | 5 ms
6,820 KB |
testcase_10 | AC | 6 ms
6,816 KB |
testcase_11 | AC | 189 ms
11,108 KB |
testcase_12 | AC | 361 ms
12,456 KB |
testcase_13 | AC | 315 ms
8,320 KB |
testcase_14 | AC | 186 ms
12,404 KB |
testcase_15 | AC | 144 ms
13,144 KB |
testcase_16 | AC | 285 ms
7,552 KB |
testcase_17 | AC | 79 ms
8,960 KB |
testcase_18 | AC | 220 ms
9,088 KB |
testcase_19 | AC | 370 ms
9,472 KB |
testcase_20 | AC | 132 ms
10,668 KB |
testcase_21 | AC | 342 ms
14,160 KB |
testcase_22 | AC | 335 ms
14,200 KB |
testcase_23 | AC | 119 ms
7,936 KB |
testcase_24 | AC | 4 ms
6,820 KB |
testcase_25 | AC | 4 ms
6,820 KB |
testcase_26 | AC | 375 ms
14,248 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; using ld=long double; constexpr ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++) #define all(v) v.begin(),v.end() #define len(v) ((ll)v.size()) template<class T> inline bool chmin(T &a,T b){ if(a>b){ a=b; return true; } return false; } template<class T> inline bool chmax(T &a,T b){ if(a<b){ a=b; return true; } return false; } template<class T> struct fenwick_tree{ vector<T> v; int n; fenwick_tree(int x){ n=x; v.assign(n+1,0); } fenwick_tree(vector<T> &a){ n=(int)a.size(); v.assign(n+1,0); for(int i=0;i<n;i++) v[i+1]=a[i]; for(int idx=1;idx<=n;idx++){ if(n<idx+(idx&(-idx))) continue; v[idx+(idx&(-idx))]+=v[idx]; } } void add(int i,T x){ assert(0<=i&&i<n); i++; for(int idx=i;idx<=n;idx+=(idx&(-idx))){ v[idx]+=x; } } T sum(int r){ //[0,r] r++; T ret=0; for(int idx=r;0<idx;idx-=(idx&(-idx))){ ret+=v[idx]; } return ret; } T sum(int l,int r){ //[l,r] assert(0<=l&&l<n); assert(0<=r&&r<n); assert(l<=r); if(l==0) return sum(r); return sum(r)-sum(l-1); } int lower_bound(T w){ if(w<=0) return 0; int x=0; static int r=1; if(r==1){ while((r<<1)<=n) r<<=1; } while((r<<1)<=n) r<<=1; for(int k=r;0<k;k>>=1){ if(x+k<=n&&v[x+k]<w){ w-=v[x+k]; x+=k; } } return x; } }; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll n,q,l0; cin >> n >> q >> l0; ll sz=(ll)2e5+1; fenwick_tree<ll> cnt(sz),sum(sz); vector<ll> a(n); rep(i,n){ cin >> a[i]; cnt.add(a[i],1); sum.add(a[i],a[i]); } bool found=false; while(q--){ ll t; cin >> t; if(t==1){ ll l; cin >> l; cnt.add(l,1); sum.add(l,l); } if(t==2){ ll l,r; cin >> l >> r; cout << cnt.sum(l,r) << ' ' << sum.sum(l,r) << '\n'; found=true; } if(t==3){ ll m; cin >> m; } } if(!found) cout << "Not Found!\n"; }