結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
Alice_Entity
|
| 提出日時 | 2017-09-11 00:12:56 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 567 bytes |
| コンパイル時間 | 430 ms |
| コンパイル使用メモリ | 29,440 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 12:54:28 |
| 合計ジャッジ時間 | 1,373 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 3 |
| other | AC * 18 WA * 12 |
ソースコード
#include<stdio.h>
int main (void){
int N,A[1000],ans[1000],i;
scanf("%d",&N);
for(i=0;i<N;i++){
scanf("%d",&A[i]);
}
if(N == 1){
printf("%d",A[0]);
return 0;
}
if(N == 2){
if(A[0]<A[1]){
printf("%d",A[1]);
return 0;
}else{
printf("%d",A[0]);
return 0;
}
}
if(A[1]<A[0]+A[2]){
ans[2] = A[0]+A[2];
}else {
ans[2] = A[1];
}
for(i=3;i<=N-1;i++){
if(ans[i-1] < ans[i-2]+A[i]){
ans[i] = ans[i-2]+A[i];
}else {
ans[i] = ans[i-1];
}
}
printf("%d",ans[N-1]);
}
Alice_Entity