結果

問題 No.865 24時間降水量
ユーザー tonegawatonegawa
提出日時 2020-08-20 15:26:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 393 ms / 2,000 ms
コード長 1,114 bytes
コンパイル時間 870 ms
コンパイル使用メモリ 85,688 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 12:45:04
合計ジャッジ時間 3,569 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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