結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
|
| 提出日時 | 2021-02-10 21:15:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 583 bytes |
| コンパイル時間 | 1,567 ms |
| コンパイル使用メモリ | 170,808 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-08 08:30:37 |
| 合計ジャッジ時間 | 2,682 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
int N;
cin >> N;
vector<vector<int>>dp(N+1, vector<int>(2, 0));
for (int i=0; i<N; i++) {
int n;
cin >> n;
dp[i+1][1] = dp[i][0] + n;
dp[i+1][0] = max(dp[i][1], dp[i][0]);
}
cout << max(dp[N][0], dp[N][1]) << endl;
return 0;
}