結果
| 問題 | No.45 回転寿司 |
| ユーザー |
compass19
|
| 提出日時 | 2017-01-11 23:08:00 |
| 言語 | C90 (gcc 12.4.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 334 bytes |
| 記録 | |
| コンパイル時間 | 73 ms |
| コンパイル使用メモリ | 26,560 KB |
| 最終ジャッジ日時 | 2025-12-04 17:38:37 |
| 合計ジャッジ時間 | 562 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:8:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
8 | for (int i = 0; i < n; i++) scanf("%d", &v[i]);
| ^~~
main.c:8:9: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code
main.c:14:18: error: redefinition of 'i'
14 | for (int i = 0; i < n; ++i)
| ^
main.c:8:18: note: previous definition of 'i' with type 'int'
8 | for (int i = 0; i < n; i++) scanf("%d", &v[i]);
| ^
main.c:14:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
14 | for (int i = 0; i < n; ++i)
| ^~~
ソースコード
#include<stdio.h>
#define max(a, b) (a > b)?a:b
int main(){
// データ読み込み
int n;
scanf("%d", &n);
int v[n];
for (int 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