結果

問題 No.45 回転寿司
ユーザー Hissha_
提出日時 2018-03-29 21:43:10
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 776 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 29,696 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-25 23:53:54
合計ジャッジ時間 2,489 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 1 WA * 22 RE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

#include <stdlib.h>

 

int maxv(int n, int v[]){

              int i;

//            for(i=0;i<n-1;i++) printf("%d ", *(v+i));

              if(n==0) return v[0];

              if(n==1) return v[1]>v[0]?v[1]:v[0];

              return v[n-2]<v[n-1]?(maxv(n-3,v)+v[n-1]):(maxv(n-2,v));

}

 

int main(void) {

              // your code goes here

              int i, n;

              int *v;

 

              scanf("%d",&n);

              v = (int *)malloc(sizeof(int) * n);

             

              if(v==NULL) exit(0);

              for(i=0;i<n-1;i++){

                            scanf("%d ",v+i);

              }

              scanf("%d",v+n-1);

             

              printf("%d\n",maxv(n,v));

 

              return 0;

}
0