結果

問題 No.865 24時間降水量
ユーザー lemty
提出日時 2019-08-16 23:13:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 2,289 ms
コンパイル使用メモリ 195,956 KB
最終ジャッジ日時 2025-01-07 12:50:23
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other WA * 15 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &x : a)
    cin >> x;
  vector<int> A(n + 1);
  for (int i = 0; i < n; i++)
    A[i + 1] = A[i] + a[i];

  vector<int> b(n - 24 + 1);
  for (int i = 0; i + 24 <= n; i++) {
    b[i] = A[i + 24] - A[i];
  }

  int q;
  cin >> q;
  while (--q >= 0) {
    int t, v;
    cin >> t >> v;
    t--;
    int d = v - a[t];
    for (int i = max(0, t - 23); i < min(n, (t + 24) / 24); i++) {
      b[i] += d;
    }
    cout << *max_element(b.begin(), b.end()) << endl;
  }

  return 0;
}
0