結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
sei0o
|
| 提出日時 | 2017-10-17 13:10:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 683 bytes |
| コンパイル時間 | 1,018 ms |
| コンパイル使用メモリ | 81,488 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 17:31:29 |
| 合計ジャッジ時間 | 2,345 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dp[1010][2]; // dp[i][k] = i番目までのお寿司でi番目のsushiを取った場合の最大の「うまい!w」
int main() {
int N;
cin >> N;
int a[N];
for (int i = 0; i < N; i++) cin >> a[i];
for (int i = 0; i < N; i++) {
// sushiを取る
dp[i+1][1] = dp[i][0] + a[i];
// sushiを取らない
dp[i+1][0] = max(dp[i][1], dp[i][0]);
}
cout << max(dp[N][0], dp[N][1]) << endl;
return 0;
}
sei0o