結果
問題 | No.45 回転寿司 |
ユーザー |
|
提出日時 | 2016-11-11 01:12:33 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 570 bytes |
コンパイル時間 | 1,679 ms |
コンパイル使用メモリ | 82,380 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 15:36:16 |
合計ジャッジ時間 | 3,061 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#define _USE_MATH_DEFINES #include<stdio.h> #include<string> #include<iostream> #include<cctype> #include<cstdio> #include<vector> #include<stack> #include<queue> #include <algorithm> #include<math.h> #include<set> #include<map> #include<iomanip> //#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; vector<int>y(n),v(n); for(int i=0;i<n;i++){ cin>>y[i]; } if(n==1){ cout<<y[0]<<endl; return 0; } v[0]=y[0]; v[1]=max(y[0],y[1]); for(int i=2;i<n;i++){ v[i]=max(v[i-1],v[i-2]+y[i]); } cout<<v[n-1]<<endl; return 0; }