結果
| 問題 | No.45 回転寿司 |
| ユーザー |
compass19
|
| 提出日時 | 2017-01-11 23:10:37 |
| 言語 | C90 (gcc 12.4.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 338 bytes |
| 記録 | |
| コンパイル時間 | 314 ms |
| コンパイル使用メモリ | 21,700 KB |
| 最終ジャッジ日時 | 2026-01-11 03:39:38 |
| 合計ジャッジ時間 | 1,345 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c: In function ‘main’:
main.c:4:9: error: C++ style comments are not allowed in ISO C90
4 | // データ読み込み
| ^
main.c:4:9: note: (this will be reported only once per input file)
main.c:15:18: error: redeclaration of ‘i’ with no linkage
15 | for (int i = 0; i < n; ++i)
| ^
main.c:8:13: note: previous declaration of ‘i’ with type ‘int’
8 | int i;
| ^
main.c:15:9: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
15 | for (int i = 0; i < n; ++i)
| ^~~
main.c:15:9: note: use option ‘-std=c99’, ‘-std=gnu99’, ‘-std=c11’ or ‘-std=gnu11’ to compile your code
main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
main.c:9:33: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | for (i = 0; i < n; i++) scanf("%d", &v[i]);
| ^~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#define max(a, b) (a > b)?a:b
int main(){
// データ読み込み
int n;
scanf("%d", &n);
int v[n];
int i;
for (i = 0; i < n; i++) scanf("%d", &v[i]);
// main
int p = 0;
int q = 0;
int tmp_p;
for (int i = 0; i < n; ++i)
{
tmp_p = p;
p = v[i] + q;
q = max(tmp_p, q);
}
printf("%d\n", max(p, q));
}
compass19