結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
Microbe
|
| 提出日時 | 2017-08-08 17:16:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 799 bytes |
| コンパイル時間 | 1,533 ms |
| コンパイル使用メモリ | 166,372 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 16:48:15 |
| 合計ジャッジ時間 | 2,542 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF INT_MAX
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P, int> Pi;
const int MOD = 1000000007;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
int v[1000];
int dp[1001];
int main() {
int n;
scanf("%d", &n);
rep(i, n) scanf("%d", &v[i]);
dp[0] = 0;
dp[1] = v[0];
FOR(i, 2, n + 1) {
dp[i] = max(dp[i - 1], dp[i - 2] + v[i - 1]);
}
printf("%d\n", dp[n]);
return 0;
}
Microbe