結果

問題 No.45 回転寿司
ユーザー shinchan
提出日時 2019-03-15 19:47:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 726 bytes
コンパイル時間 1,732 ms
コンパイル使用メモリ 158,056 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-01 20:05:00
合計ジャッジ時間 2,919 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    }
    cout << dp[n-1]<<endl;
    return 0;
}

0