結果
問題 | No.865 24時間降水量 |
ユーザー |
![]() |
提出日時 | 2019-08-16 21:52:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,162 bytes |
コンパイル時間 | 2,447 ms |
コンパイル使用メモリ | 195,128 KB |
最終ジャッジ日時 | 2025-01-07 12:14:53 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 1 |
ソースコード
#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; }