結果

問題 No.865 24時間降水量
ユーザー ngtkanangtkana
提出日時 2019-08-16 21:52:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,162 bytes
コンパイル時間 2,375 ms
コンパイル使用メモリ 204,488 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-23 22:40:46
合計ジャッジ時間 4,313 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_geneous = 0; ngtkana_is_geneous < n; ngtkana_is_geneous++)
#define rep(i, begin, end) for(int i = begin; i < end; i++)

template<typename T, typename U>
inline auto cmn (T& a, U b) {if (a > b) {a = b; return true;} return false;}
template<typename T, typename U>
inline auto cmx (T& a, U b) {if (a < b) {a = b; return true;} return false;}

int main()
{
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n);
  for (auto & x : a) std::cin >> x;
  int k = 24;
  int max = 0;
  int sum = std::accumulate(a.begin(), a.begin() + 24, 0);
  for (int i = 0; i < n - k; i++)
  {
    sum -= a.at(i);
    sum += a.at(i + k);
    cmx(max, sum);
  }
  int q; std::cin >> q;
  while (q--)
  {
    int t, v; std::cin >> t >> v;
    t--;
    a.at(t) = v;
    int l = std::max(t - k + 1, 0), r = l + k;
    int sum = std::accumulate(a.begin() + l, a.begin() + r, 0);
    cmx(max, sum);
    while (r <= std::min(t + k, n) - 1)
    {
      sum -= a.at(l);
      sum += a.at(r);
      cmx(max, sum);
      l++, r++;
    }
    std::cout << max << std::endl;
  }
  return 0;
}
0