結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
shinchan
|
| 提出日時 | 2019-03-15 19:53:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 772 bytes |
| コンパイル時間 | 3,405 ms |
| コンパイル使用メモリ | 157,672 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 20:09:56 |
| 合計ジャッジ時間 | 2,657 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
int dp[n];
for(int i=0;i<n;i++){
dp[i]=a[i];
int maki=0;
for(int j=i-2;j>=0;j--){
maki=max(dp[j],maki);
}
dp[i]+=maki;
}
int ans=(n==1)?dp[n-1]:max(dp[n-1],dp[n-2]);
cout << ans<<endl;
return 0;
}
shinchan