結果
問題 | No.865 24時間降水量 |
ユーザー |
![]() |
提出日時 | 2019-08-16 22:14:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 359 ms / 2,000 ms |
コード長 | 2,434 bytes |
コンパイル時間 | 2,415 ms |
コンパイル使用メモリ | 198,404 KB |
最終ジャッジ日時 | 2025-01-07 12:20:17 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#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++)#define LOCALusing std::to_string;auto to_string(std::string s) -> std::string {return '"' + s + '"';}auto to_string(char c) -> std::string {return "'" + std::string{c} + "'";}auto to_string(const char* s) -> std::string {return to_string((std::string) s);}auto to_string(bool b) -> std::string {return (b ? "true" : "false");}template <typename T, typename U>auto to_string(std::pair<T, U> p) -> std::string {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <size_t N>auto to_string(std::bitset<N> bs) -> std::string {std::string res{};for (size_t i = 0; i < N; i++)res.insert(res.begin(), bs.test(i) ? '1' : '0');return res;}template <typename T>auto to_string(T v) -> std::string {bool flg = false;std::string res = "{";for (auto const&x : v) {if (flg) res += ", ";else flg = true;res += to_string(x);}res += "}";return res;}void debug_out() { std::cerr << std::endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {std::cerr << " " << to_string(H);debug_out(T...);}#ifdef LOCAL#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)#else#define debug(...) 42#endiftemplate<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 sum = std::accumulate(a.begin(), a.begin() + 24, 0);int max = sum;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 (true){cmx(max, sum);if (r == std::min(t + k, n)) break;sum -= a.at(l);sum += a.at(r);l++, r++;}std::cout << max << std::endl;}return 0;}