結果
| 問題 | No.3164 [Chery 7th Tune B] La vie en rose |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2025-05-31 16:50:48 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 89 ms / 2,000 ms |
| + 386µs | |
| コード長 | 927 bytes |
| 記録 | |
| コンパイル時間 | 170 ms |
| コンパイル使用メモリ | 52,684 KB |
| 実行使用メモリ | 7,552 KB |
| 最終ジャッジ日時 | 2026-07-11 05:19:02 |
| 合計ジャッジ時間 | 9,759 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 34 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 3164.cc: No.3164 [Chery 7th Tune B] La vie en rose - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 300000;
/* typedef */
using ll = long long;
/* global variables */
int as[MAX_N];
ll ass[MAX_N];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", as + i);
for (int i = 0; i < n;) {
while (i < n && as[i] == 0) i++;
if (i >= n) break;
int j = i;
ll s = 0;
while (i < n && as[i] > 0) s += as[i++];
while (j < i) ass[j++] = s;
}
int qn;
scanf("%d", &qn);
while (qn--) {
int x, b;
scanf("%d%d", &x, &b), x--;
ll s = ass[x] - as[x] + b;
if (as[x] == 0) {
if (x > 0 && as[x - 1] > 0) s += ass[x - 1];
if (x + 1 < n && as[x + 1] > 0) s += ass[x + 1];
}
printf("%lld\n", s);
}
return 0;
}
tnakao0123