結果

問題 No.324 落ちてた閉路グラフ
コンテスト
ユーザー 👑 tails
提出日時 2015-12-17 01:32:57
言語 C90
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 455 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 189 ms
コンパイル使用メモリ 30,024 KB
最終ジャッジ日時 2026-02-23 20:07:01
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31 WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | d[3010][2][2];
      | ^
main.c:2:1: warning: data definition has no type or storage class
    2 | w[3010];
      | ^
main.c: In function ‘main’:
main.c:5:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
    5 |         scanf("%d%d",&n,&m);
      |         ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | d[3010][2][2];
main.c:12:9: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
   12 |         printf("%d",max(max(d[m][0][0],d[m][0][1]),max(d[m][1][0],d[m][1][1]+w[n-1])));
      |         ^~~~~~
main.c:12:9: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’

ソースコード

diff #
raw source code

d[3010][2][2];
w[3010];
max(a,b){return a>b?a:b;}
main(i,j,k,n,m){
	scanf("%d%d",&n,&m);
	for(i=0;i<n;++i)scanf("%d",w+i);
	for(k=n;k>=0;--k)for(j=0;j<2;++j)d[k][j][0]=d[k][j][1]=-999;
	d[0][0][0]=d[1][1][1]=0;
	for(i=1;i<n;++i)for(k=i+1;k>=0;--k)for(j=0;j<2;++j)
		d[k][j][0]=max(d[k][j][0],d[k][j][1]),
		k&&(d[k][j][1]=max(d[k-1][j][0],d[k-1][j][1]+w[i-1]));
	printf("%d",max(max(d[m][0][0],d[m][0][1]),max(d[m][1][0],d[m][1][1]+w[n-1])));
	return 0;
}
0