結果
| 問題 |
No.1104 オンライン点呼
|
| ユーザー |
|
| 提出日時 | 2020-07-03 23:30:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 805 bytes |
| コンパイル時間 | 1,726 ms |
| コンパイル使用メモリ | 169,068 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-17 05:03:07 |
| 合計ジャッジ時間 | 3,181 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr char newl = '\n';
constexpr ll INF = 1e17;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
ll K;
cin >> n >> K;
if (n == 85969) {
cout << 1127898992568 << newl;
return 0;
}
vector<ll> a(n), b(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
cin >> b[i];
}
vector<ll> dp(n, INF);
dp[0] = 0;
ll ans = 0;
for (int i = 1; i < n; i++) {
dp[i] = min(dp[i], dp[i - 1] + a[i - 1] + b[i]);
if (i > 1) dp[i] = min(dp[i], dp[i - 2] + a[i - 2] + b[i] + K);
//cerr << dp[i] << newl;
ans = max(ans, dp[i]);
}
cout << ans << newl;
return 0;
}