結果

問題 No.865 24時間降水量
ユーザー tonetone
提出日時 2019-08-21 19:15:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 406 ms / 2,000 ms
コード長 1,114 bytes
コンパイル時間 2,313 ms
コンパイル使用メモリ 79,272 KB
実行使用メモリ 4,732 KB
最終ジャッジ日時 2023-07-30 18:41:28
合計ジャッジ時間 4,850 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 19 ms
4,376 KB
testcase_11 AC 19 ms
4,380 KB
testcase_12 AC 19 ms
4,376 KB
testcase_13 AC 19 ms
4,384 KB
testcase_14 AC 19 ms
4,380 KB
testcase_15 AC 399 ms
4,640 KB
testcase_16 AC 401 ms
4,732 KB
testcase_17 AC 406 ms
4,608 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,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