結果
問題 | No.865 24時間降水量 |
ユーザー |
![]() |
提出日時 | 2019-08-16 21:40:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,148 bytes |
コンパイル時間 | 2,400 ms |
コンパイル使用メモリ | 194,536 KB |
最終ジャッジ日時 | 2025-01-07 12:13:16 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 1 |
コンパイルメッセージ
In function ‘S chmax(S&, T) [with S = int; T = int]’, inlined from ‘int main()’ at main.cpp:83:8: main.cpp:59:3: warning: ‘res’ is used uninitialized [-Wuninitialized] 59 | if(a<b){ | ^~ main.cpp: In function ‘int main()’: main.cpp:70:20: note: ‘res’ was declared here 70 | int KL2GvlyY, i, res, s, x, y; | ^~~
ソースコード
#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);i++){ s += A[i] - A[i-24]; chmax(res, s); } wt_L(res); wt_L('\n'); } return 0; } // cLay varsion 20190810-2 // --- 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){ // s += A[i] - A[i-24]; // res >?= s; // } // // wt(res); // } // }