結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
|
| 提出日時 | 2016-03-29 13:15:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 605 bytes |
| コンパイル時間 | 1,423 ms |
| コンパイル使用メモリ | 60,792 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 13:05:52 |
| 合計ジャッジ時間 | 2,790 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int n;
std::cin >> n;
std::vector<int> v(n);
for(int i=0; i<n; ++i){
int tmp;
std::cin >> tmp;
switch(i){
case 0:
v[0]=tmp;
break;
case 1:
v[1]=std::max(tmp, v[0]);
break;
default:
v[i]=std::max(v[i-1], v[i-2]+tmp);
break;
}
}
std::cout << v[n-1] << "\n";
return 0;
}