結果
| 問題 |
No.865 24時間降水量
|
| コンテスト | |
| ユーザー |
LayCurse
|
| 提出日時 | 2019-08-21 05:59:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| コード長 | 2,183 bytes |
| コンパイル時間 | 2,156 ms |
| コンパイル使用メモリ | 211,792 KB |
| 最終ジャッジ日時 | 2025-01-07 14:29:02 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
コンパイルメッセージ
In function ‘S chmax(S&, T) [with S = int; T = int]’,
inlined from ‘int main()’ at main.cpp:84:8:
main.cpp:60:3: warning: ‘res’ is used uninitialized [-Wuninitialized]
60 | if(a<b){
| ^~
main.cpp: In function ‘int main()’:
main.cpp:71:20: note: ‘res’ was declared here
71 | int KL2GvlyY, i, res, s, x, y;
| ^~~
ソースコード
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
return a<=b?a:b;
}
template<class S, class T> inline S max_L(S a,T b){
return a>=b?a:b;
}
inline void rd(int &x){
int k, m=0;
x=0;
for(;;){
k = getchar_unlocked();
if(k=='-'){
m=1;
break;
}
if('0'<=k&&k<='9'){
x=k-'0';
break;
}
}
for(;;){
k = getchar_unlocked();
if(k<'0'||k>'9'){
break;
}
x=x*10+k-'0';
}
if(m){
x=-x;
}
}
inline void wt_L(char a){
putchar_unlocked(a);
}
inline void wt_L(int x){
char f[10];
int m=0, s=0;
if(x<0){
m=1;
x=-x;
}
while(x){
f[s++]=x%10;
x/=10;
}
if(!s){
f[s++]=0;
}
if(m){
putchar_unlocked('-');
}
while(s--){
putchar_unlocked(f[s]+'0');
}
}
template<class S, class T> inline S chmax(S &a, T b){
if(a<b){
a=b;
}
return a;
}
int N;
int A[200000];
int Q;
int T;
int V;
int main(){
int KL2GvlyY, i, res, s, x, y;
rd(N);
{
int Lj4PdHRW;
for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
rd(A[Lj4PdHRW]);
}
}
rd(Q);
s = 0;
for(i=0;i<(24);i++){
s += A[i];
}
chmax(res, s);
for(i=(24);i<(N);i++){
s += A[i] - A[i-24];
chmax(res, s);
}
for(KL2GvlyY=0;KL2GvlyY<(Q);KL2GvlyY++){
rd(T);T += (-1);
rd(V);
A[T] = V;
x =max_L(0, T-24);
y =min_L(N-1, T+24);
s = 0;
for(i=(x);i<(x+24);i++){
s+= A[i];
}
chmax(res, s);
for(i=(x+24);i<(y+1);i++){
s += A[i] - A[i-24];
chmax(res, s);
}
wt_L(res);
wt_L('\n');
}
return 0;
}
// cLay varsion 20190820-1
// --- original code ---
// int N, A[2d5], Q, T, V;
// {
// int i, x, y, s, res;
// rd(N,A(N),Q);
//
// s = 0;
// rep(i,24) s += A[i];
// res >?= s;
// rep(i,24,N){
// s += A[i] - A[i-24];
// res >?= s;
// }
//
// rep(Q){
// rd(T--,V);
// A[T] = V;
// x = max(0, T-24);
// y = min(N-1, T+24);
//
// s = 0;
// rep(i,x,x+24) s+= A[i];
// res >?= s;
// rep(i,x+24,y+1){
// s += A[i] - A[i-24];
// res >?= s;
// }
//
// wt(res);
// }
// }
LayCurse