結果

問題 No.865 24時間降水量
ユーザー onakaT_TitaionakaT_Titai
提出日時 2019-08-16 22:38:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 406 ms / 2,000 ms
コード長 2,149 bytes
コンパイル時間 1,484 ms
コンパイル使用メモリ 117,912 KB
実行使用メモリ 7,264 KB
最終ジャッジ日時 2023-10-24 01:58:10
合計ジャッジ時間 3,717 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 4 ms
4,348 KB
testcase_06 AC 4 ms
4,348 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 20 ms
4,348 KB
testcase_11 AC 20 ms
4,348 KB
testcase_12 AC 20 ms
4,348 KB
testcase_13 AC 20 ms
4,348 KB
testcase_14 AC 20 ms
4,348 KB
testcase_15 AC 404 ms
7,264 KB
testcase_16 AC 404 ms
7,264 KB
testcase_17 AC 406 ms
7,264 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 #

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

vector<long long> Divisor(long long n) {
    vector<long long> ret;
    for(long long i=1; i*i<=n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n / i);
        }
    }
    return ret;
}

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    int Q;
    cin >> Q;
    vector<pair<int, int>> Query(Q);
    for (int i = 0; i < Q; i++) {
        cin >> Query[i].first >> Query[i].second;
        Query[i].first--;
    }

    vector<long long> sum24(N);
    long long ans = 0;
    for (int i = 0; i < N-23; i++) {
        for (int j = 0; j < 24; j++) {
            sum24[i] += A[i+j];
        }
        ans = max(sum24[i], ans);
    }
    for (int i = 0; i < Q; i++) {
        for (int j = max(0, Query[i].first - 23); j <= Query[i].first; j++) {
            sum24[j] += (Query[i].second - A[Query[i].first]);
            ans = max(sum24[j], ans);
        }
        A[Query[i].first] = Query[i].second;
        cout << ans << endl;
    }
}
0