結果
| 問題 | 
                            No.865 24時間降水量
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tonegawa
                         | 
                    
| 提出日時 | 2020-08-20 15:26:44 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 479 ms / 2,000 ms | 
| コード長 | 1,114 bytes | 
| コンパイル時間 | 1,009 ms | 
| コンパイル使用メモリ | 86,412 KB | 
| 最終ジャッジ日時 | 2025-01-13 04:25:43 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 18 | 
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;
int main(int argc, char const *argv[]) {
  ll N, Q, T, V;
  std::cin >> N;
  std::vector<ll> A(N);
  for(int i=0;i<N;i++) std::cin >> A[i];
  ll ans = 0;
  for(int i=0;i<N-23;i++){
    ll candi = 0;
    for(int j=0;j<24;j++){
      candi+=A[i+j];
    }
    ans = max(ans, candi);
  }
  std::cin >> Q;
  std::vector<ll> left(24, 0), right(24, 0);
  for(int i=0;i<Q;i++){
    std::cin >> T >> V;
    T--;
    A[T]=V;
    for(int j=1;j<24;j++){
      left[j] = (T-j<0?-1:left[j-1] + A[T-j]);
      right[j] = (T+j>=N?-1:right[j-1]+A[T+j]);
    }
    for(int j=0;j<24;j++){
      if(left[j] ==-1 || right[23-j]== -1) continue;
      ll candi = A[T] + left[j] + right[23-j];
      ans = max(ans, candi);
    }
    std::cout << ans << '\n';
  }
  return 0;
}
            
            
            
        
            
tonegawa