結果

問題 No.45 回転寿司
ユーザー Hissha_Hissha_
提出日時 2018-03-29 21:43:10
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 776 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 28,384 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 06:39:04
合計ジャッジ時間 2,960 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 RE -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 0 ms
4,376 KB
testcase_24 AC 0 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 RE -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 RE -
testcase_31 WA -
testcase_32 AC 0 ms
4,376 KB
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

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