結果
| 問題 |
No.3164 [Chery 7th Tune B] La vie en rose
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2025-05-31 01:23:41 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 162 ms / 2,000 ms |
| コード長 | 791 bytes |
| コンパイル時間 | 2,886 ms |
| コンパイル使用メモリ | 280,888 KB |
| 実行使用メモリ | 9,232 KB |
| 最終ジャッジ日時 | 2025-05-31 01:23:59 |
| 合計ジャッジ時間 | 16,466 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 34 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
cin>>n;
V<ll> A(n+2);
V<int> B;
B.push_back(0);
rep(i,n){
cin>>A[i+1];
if(A[i+1]==0) B.push_back(i+1);
}
B.push_back(n+1);
V<ll> S(n+2);
rep(i,n+1) S[i+1]=S[i]+A[i];
int q;
cin>>q;
while(q--){
ll x,b;
cin>>x>>b;
if(A[x]==0){
auto r=upper_bound(ALL(B),x)-B.begin();
cout<<S[B[r]]-S[B[r-2]]+b<<'\n';
}
else{
auto r=upper_bound(ALL(B),x)-B.begin();
cout<<S[B[r]]-S[B[r-1]]+b-A[x]<<'\n';
}
}
return 0;
}
umezo