結果

問題 No.865 24時間降水量
ユーザー 夜
提出日時 2020-10-28 02:56:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 490 ms / 2,000 ms
コード長 1,148 bytes
コンパイル時間 763 ms
コンパイル使用メモリ 93,556 KB
実行使用メモリ 6,252 KB
最終ジャッジ日時 2023-09-29 03:30:37
合計ジャッジ時間 4,616 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 3 ms
4,648 KB
testcase_02 AC 3 ms
4,548 KB
testcase_03 AC 2 ms
4,508 KB
testcase_04 AC 3 ms
4,528 KB
testcase_05 AC 5 ms
4,516 KB
testcase_06 AC 5 ms
4,588 KB
testcase_07 AC 5 ms
4,520 KB
testcase_08 AC 5 ms
4,644 KB
testcase_09 AC 5 ms
4,528 KB
testcase_10 AC 23 ms
4,564 KB
testcase_11 AC 23 ms
4,620 KB
testcase_12 AC 23 ms
4,384 KB
testcase_13 AC 23 ms
4,496 KB
testcase_14 AC 23 ms
4,532 KB
testcase_15 AC 486 ms
6,192 KB
testcase_16 AC 485 ms
6,204 KB
testcase_17 AC 490 ms
6,252 KB
testcase_18 AC 2 ms
4,500 KB
testcase_19 AC 3 ms
4,492 KB
testcase_20 AC 3 ms
4,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long n;
vector<long long> BIT(200020);
long long a[200020];
void add(long long i, long long x) {
	while (i <= n) {
		BIT[i] += x;
		i += i & -i;
	}
}
long long csum(long long i) {
	long long count = 0;
	while (i > 0) {
		count += BIT[i];
		i -= i & -i;
	}
	return count;
}
long long sum(long long l, long long r) {
	return csum(r) - csum(l - 1);
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		add(i, a[i]);
	}
	long long ans = 0;
	for (int i = 1; i <= n - 23; i++) {
		long long s = sum(i, i + 23);
		if (ans < s) {
			ans = s;
		}
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int t, v;
		cin >> t >> v;
		add(t, v - a[t]);
		a[t] = v;
		for (int j = t - 23; j <= t; j++) {
			if (j > 0 && j + 23 <= n) {
				long long s1 = sum(j, j + 23);
				if (ans < s1) {
					ans = s1;
				}
			}
		}
		cout << ans << endl;
	}
}
0