結果

問題 No.45 回転寿司
ユーザー hotchstar
提出日時 2017-07-02 18:46:39
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 580 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 202 ms
コンパイル使用メモリ 42,360 KB
最終ジャッジ日時 2026-02-22 00:02:46
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int v[1000];
int dp[1001];
int main(void)
{
    int n,i;
    scanf("%d",&n);
    FOR(i,0,n) scanf("%d",&v[i]);
    dp[0]=0,dp[1]=v[0];
    FOR(i,2,n+1) dp[i]=MAX(dp[i-1],dp[i-2]+v[i-1]);
    printf("%d\n",dp[n]);
 	return 0;
}
0