結果

問題 No.45 回転寿司
ユーザー kidman_univ
提出日時 2019-05-01 22:10:25
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,069 bytes
コンパイル時間 812 ms
コンパイル使用メモリ 83,728 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-27 20:33:31
合計ジャッジ時間 2,109 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;


int main(){
    int n; cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];

    int dp[n+1][2];
    rep(i,n+1) rep(j,2) dp[i][j] = 0;
    rep(i,n){
        
        dp[i+1][1] = dp[i][0] + a[i];

        dp[i+1][0] = max(dp[i][1],dp[i][0]);

    }
    //cout << dp[n][0] << " " <<  dp[n][1] << endl;
    cout << max(dp[n][0],dp[n][1]) << endl;

}
0