結果
問題 | No.865 24時間降水量 |
ユーザー |
![]() |
提出日時 | 2019-08-16 21:51:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 415 ms / 2,000 ms |
コード長 | 863 bytes |
コンパイル時間 | 754 ms |
コンパイル使用メモリ | 73,604 KB |
最終ジャッジ日時 | 2025-01-07 12:14:34 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <iostream>#include <algorithm>#include <vector>using namespace std;int n,t[400010] = {},mx = 0;void built(){for(int i = n-1;i>0;i--){t[i] = t[i<<1] + t[i<<1|1];}}void update(int p,int a){for(t[p+=n] = a;p>1;p >>= 1){t[p>>1] = t[p] + t[p^1];}}int query(int l, int r){int mn = mx;for(l += n, r += n; l<r; l >>= 1,r >>= 1){if(l&1) mn += t[l++];if(r&1) mn += t[--r];}return mn;}int main(){ios_base::sync_with_stdio(false);cin.tie(NULL);int i,j,q;cin >> n;for(i=0;i<n;i++){int a; cin >> a; t[i + n] = a;}built();int mx = -1;for(i=0;i<=n - 24;i++){mx = max(mx,query(i,i + 24));}cin >> q;for(i=0;i<q;i++){int t,v; cin >> t >> v;t--; update(t,v);for(j=t - 24;j<=t;j++){if(j<0) continue;if(j + 24>n) continue;mx = max(mx,query(j,j + 24));}cout << mx << endl;}}