結果

問題 No.865 24時間降水量
ユーザー Imperi_NightImperi_Night
提出日時 2019-08-16 21:56:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 1,583 bytes
コンパイル時間 908 ms
コンパイル使用メモリ 97,888 KB
実行使用メモリ 6,388 KB
最終ジャッジ日時 2023-10-23 23:01:16
合計ジャッジ時間 2,679 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 2 ms
4,372 KB
testcase_10 AC 4 ms
4,372 KB
testcase_11 AC 4 ms
4,372 KB
testcase_12 AC 5 ms
4,372 KB
testcase_13 AC 5 ms
4,372 KB
testcase_14 AC 5 ms
4,372 KB
testcase_15 AC 68 ms
6,388 KB
testcase_16 AC 68 ms
6,388 KB
testcase_17 AC 68 ms
6,388 KB
testcase_18 AC 2 ms
4,372 KB
testcase_19 AC 2 ms
4,372 KB
testcase_20 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0