結果

問題 No.865 24時間降水量
コンテスト
ユーザー RasShalGul
提出日時 2026-08-23 21:50:56
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.90.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 338 ms / 2,000 ms
+ 100µs
コード長 1,184 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,532 ms
コンパイル使用メモリ 359,356 KB
実行使用メモリ 9,472 KB
最終ジャッジ日時 2026-08-23 21:51:13
合計ジャッジ時間 5,506 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
using namespace std;
const int N=2e5+5;
int n,m=24,a[N],t[N<<2];
inline void build(int p,int l,int r){
	if(l==r){
		t[p]=0;
		return;
	}
	int mid=(l+r)>>1;
	build(p<<1,l,mid);build(p<<1|1,mid+1,r);
	t[p]=max(t[p<<1],t[p<<1|1]);
}
inline void update(int p,int l,int r,int pos,int val){
	if(l==r){
		t[p]=val;
		return;
	}
	int mid=(l+r)>>1;
	if(pos<=mid){
		update(p<<1,l,mid,pos,val);
	}else{
		update(p<<1|1,mid+1,r,pos,val);
	}
	t[p]=max(t[p<<1],t[p<<1|1]);
}
signed main(){
	//freopen("precipitation.in","r",stdin);
	//freopen("precipitation.out","w",stdout);
	IOS
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int sz=n-m+1;
	build(1,0,sz-1);
	for(int i=0;i<sz;i++){
		int sm=0;
		for(int j=0;j<m;j++){
			sm+=a[i+j];
		}
		update(1,0,sz-1,i,sm);
	}
	int q;
	cin>>q;
	while(q--){
		int pos,val;
		cin>>pos>>val;
		pos--;
		int delta=val-a[pos];
		a[pos]=val;
		int l=max(0ll,pos-m+1),r=min(pos,sz-1);
		for(int i=l;i<=r;i++){
			int sm=0;
			for(int j=0;j<m;j++){
				sm+=a[i+j];
			}
			update(1,0,sz-1,i,sm);
		}
		cout<<t[1]<<"\n";
	}
	return 0;
}
0