結果
| 問題 |
No.1375 Divide and Update
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2021-02-05 22:13:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 2,000 ms |
| コード長 | 900 bytes |
| コンパイル時間 | 1,130 ms |
| コンパイル使用メモリ | 93,916 KB |
| 最終ジャッジ日時 | 2025-01-18 12:30:14 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, x, y;
cin >> n >> x >> y;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
auto f = [&](const vector<int> &a, int x, vector<ll> &r) {
ll s = 0, t = 0, u = -(1LL << 60);
for (int i = 0; i < n; i++) {
s += a[i] - x;
r[i] = u = max(u, t - s);
t = max(t, s);
}
};
vector<ll> rx(n), ry(n);
f(a, x, rx);
reverse(a.begin(), a.end());
f(a, y, ry);
ll s = 0;
for (int i = 0; i < n; i++) {
s += a[i];
}
for (int i = 0; i < n - 2; i++) {
cout << s + rx[i] + ry[n - 3 - i] << '\n';
}
return 0;
}
merom686