結果
| 問題 | 
                            No.865 24時間降水量
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Imperi_Night
                         | 
                    
| 提出日時 | 2019-08-16 21:56:30 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 68 ms / 2,000 ms | 
| コード長 | 1,583 bytes | 
| コンパイル時間 | 935 ms | 
| コンパイル使用メモリ | 98,576 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-22 16:14:40 | 
| 合計ジャッジ時間 | 2,153 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 18 | 
ソースコード
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using ll = long long;
using P = std::pair<ll, ll>;
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"
//const ll MOD = 998244353;
const ll MOD = 1e9+7;
//とりあえず1-indexedでつくったBIT
template <class T>
struct BinaryIndexedTree {
  T n;
  std::vector<T> bit;
  BinaryIndexedTree(T i) : n(i), bit(i + 1, 0){};
  // a番目にwを加算
  void add(T a, T w) {
    for (T x = a; x <= n; x += (x & -x)) {
      bit[x] += w;
    }
  }
  //[1,a]の和
  T sum(T a) {
    T ret = 0;
    for (T x = a; x > 0; x -= (x & -x)) {
      ret += bit[x];
    }
    return ret;
  }
};
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!
  ll n;
  std::cin>>n;
  std::vector<ll> a(n),sum(n,0);
  rep(i,0,n)std::cin>>a[i];
  rep(i,0,24)sum[23]+=a[i];
  ll max=sum[23];
  rep(i,24,n){
    sum[i]=sum[i-1]+a[i]-a[i-24];
    max=std::max(max,sum[i]);
  }
  ll q;
  std::cin>>q;
  rep(i,0,q){
    ll t,v;
    std::cin>>t>>v;
    t--;
    ll temp=v-a[t];
    a[t]=v;
    rep(j,std::max((ll)23,t),std::min(n,t+24)){
      sum[j]+=temp;
      max=std::max(max,sum[j]);
    }
    std::cout<<max<<"\n";
  }
  return 0;
}
            
            
            
        
            
Imperi_Night