結果

問題 No.45 回転寿司
ユーザー compass19
提出日時 2017-01-11 23:06:31
言語 C90(gcc15)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 330 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 81 ms
コンパイル使用メモリ 25,012 KB
最終ジャッジ日時 2026-02-24 00:05:56
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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:6:19: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
    6 |         int v[n]; for (int i = 0; i < n; i++) scanf("%d", &v[i]);
      |                   ^~~
main.c:6:19: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code
main.c:12:18: error: redefinition of 'i'
   12 |         for (int i = 0; i < n; ++i)
      |                  ^
main.c:6:28: note: previous definition of 'i' with type 'int'
    6 |         int v[n]; for (int i = 0; i < n; i++) scanf("%d", &v[i]);
      |                            ^
main.c:12:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   12 |         for (int i = 0; i < n; ++i)
      |         ^~~

ソースコード

diff #
raw source code

#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));
}
0