結果

問題 No.865 24時間降水量
ユーザー pekempeypekempey
提出日時 2019-08-17 02:16:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,065 bytes
コンパイル時間 1,569 ms
コンパイル使用メモリ 169,596 KB
実行使用メモリ 5,616 KB
最終ジャッジ日時 2023-10-24 23:03:11
合計ジャッジ時間 4,377 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

const int U = 1 << 18;
int dat[U * 2];

void update(int k, int v) {
  k += U;
  dat[k] = v;
  while (k > 1) {
    k >>= 1;
    dat[k] = max(dat[k * 2], dat[k * 2 + 1]);
  }
}

int query(int l, int r) {
  l += U;
  r += U - 1;
  int ans = 0;
  for (; l <= r; l >>= 1, r >>= 1) {
    if ((l & 1) == 1) ans = max(ans, dat[l++]);
    if ((r & 1) == 0) ans = max(ans, dat[r--]);
  }
  return ans;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> A(N); rep(i, N) cin >> A[i];
  int Q; cin >> Q;
  auto calc = [&](int i) -> int {
    int ans = 0;
    rep(j, 24) ans += A[i + j];
    return ans;
  };
  rep(i, N-24+1) {
    update(i, calc(i));
  }
  while (Q--) {
    int T, V; cin >> T >> V;
    A[T - 1] = V;
    for (int i = min(N - 24, T); i >= max(0, T - 23); i--) {
      update(i, calc(i));
    }
    cout << query(0, N - 24 + 1) << '\n';
  }
}
0