結果
問題 | No.1375 Divide and Update |
ユーザー | RheoTommy |
提出日時 | 2021-02-05 23:28:11 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 354 ms / 2,000 ms |
コード長 | 1,494 bytes |
コンパイル時間 | 2,188 ms |
コンパイル使用メモリ | 202,440 KB |
実行使用メモリ | 15,024 KB |
最終ジャッジ日時 | 2023-09-15 10:54:55 |
合計ジャッジ時間 | 7,662 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,388 KB |
testcase_01 | AC | 2 ms
5,460 KB |
testcase_02 | AC | 2 ms
5,528 KB |
testcase_03 | AC | 2 ms
5,512 KB |
testcase_04 | AC | 2 ms
5,448 KB |
testcase_05 | AC | 2 ms
5,588 KB |
testcase_06 | AC | 2 ms
5,584 KB |
testcase_07 | AC | 2 ms
5,408 KB |
testcase_08 | AC | 2 ms
5,452 KB |
testcase_09 | AC | 2 ms
5,440 KB |
testcase_10 | AC | 303 ms
13,584 KB |
testcase_11 | AC | 277 ms
12,740 KB |
testcase_12 | AC | 151 ms
8,652 KB |
testcase_13 | AC | 128 ms
8,072 KB |
testcase_14 | AC | 343 ms
14,964 KB |
testcase_15 | AC | 341 ms
14,856 KB |
testcase_16 | AC | 346 ms
14,900 KB |
testcase_17 | AC | 348 ms
15,024 KB |
testcase_18 | AC | 354 ms
14,860 KB |
testcase_19 | AC | 351 ms
15,024 KB |
testcase_20 | AC | 299 ms
14,976 KB |
ソースコード
#include<bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int) n; i++) using ll = long long; using namespace std; const long long INF = 1ll << 60; void chmax(ll &x, ll y) { x = max(x, y); } void chmin(ll &x, ll y) { x = min(x, y); } ll dp[300000][3]; ll dp2[300000][3]; int main() { ll n, x, y; cin >> n >> x >> y; vector<ll> a(n); rep(i, n) cin >> a[i]; dp[0][1] = -INF; dp[0][2] = -INF; rep(i, n) { chmax(dp[i + 1][0], dp[i][0] + a[i]); chmax(dp[i + 1][2], dp[i][2] + a[i]); chmax(dp[i + 1][1], dp[i][0] + x); chmax(dp[i + 1][2], dp[i][0] + x); chmax(dp[i + 1][1], dp[i][1] + x); chmax(dp[i + 1][2], dp[i][1] + x); } // rep(i, n + 1) { // cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl; // } reverse(a.begin(), a.end()); dp2[0][1] = -INF; dp2[0][2] = -INF; rep(i, n) { chmax(dp2[i + 1][0], dp2[i][0] + a[i]); chmax(dp2[i + 1][2], dp2[i][2] + a[i]); chmax(dp2[i + 1][1], dp2[i][0] + y); chmax(dp2[i + 1][2], dp2[i][0] + y); chmax(dp2[i + 1][1], dp2[i][1] + y); chmax(dp2[i + 1][2], dp2[i][1] + y); } // rep(i, n + 1) { // cout << dp2[i][0] << " " << dp2[i][1] << " " << dp2[i][2] << endl; // } reverse(a.begin(), a.end()); for (ll i = 1; i < n - 1; i++) { cout << dp[i][2] + a[i] + dp2[n - i - 1][2] << endl; } }