結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2016-08-11 21:28:31 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 890 bytes |
コンパイル時間 | 1,106 ms |
コンパイル使用メモリ | 79,980 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 15:19:46 |
合計ジャッジ時間 | 1,787 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <algorithm> #include <iostream> #include <iomanip> #include <map> #include <numeric> #include <set> #include <sstream> #include <string> #include <vector> #include <cmath> using namespace std; #define FOR(i,s,e) for (int i = int(s); i != int(e); i++) #define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) #define ISEQ(c) (c).begin(), (c).end() int main(){ int N; cin >> N; int V[N]; FOR(i,0,N) cin >>V[i]; int mV[N]; mV[0] = V[0]; if(N == 1){ cout << mV[0] << endl; return 0; } mV[1] = max(V[0],V[1]); if(N == 2){ cout << mV[1] << endl; return 0; } FOR(i,2,N){ int max = -1; FOR(j,0,i-1){ if (V[i] + mV[j] > max) max = V[i] + mV[j]; } if (max < mV[i-1]) max = mV[i-1]; mV[i] = max; } cout << mV[N-1] << endl; return 0; }