結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2014-11-12 18:44:38 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 1,324 bytes |
コンパイル時間 | 667 ms |
コンパイル使用メモリ | 69,104 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 10:56:00 |
合計ジャッジ時間 | 1,713 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<map> #include<queue> using namespace std; template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; } template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; } template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; } template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; } #define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++) #define ALL(v) (v).begin(), (v).end() #define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());} typedef pair< double , double > Pi; typedef pair< double , Pi > Pii; int main(){ int N; cin >> N; vector< int > V(N); cin >> V; vector< int > dp(N); for(int i = 0; i < N; i++){ dp[i] = V[i]; } for(int i = 0; i < N; i++){ for(int j = N - 1; j > i + 1; j--){ dp[j] = max( dp[j], dp[i] + V[j]); } } cout << *max_element(ALL(dp)) << endl; }