結果

問題 No.286 Modulo Discount Store
コンテスト
ユーザー testestest
提出日時 2016-05-23 18:51:30
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 290 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 264 ms
コンパイル使用メモリ 30,536 KB
最終ジャッジ日時 2026-02-23 21:21:16
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | d[99999],a[20],i,j,k,n;
      | ^
main.c: In function ‘main’:
main.c:3:23: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
    3 |         for(gets(&m);~scanf("%d",a+n);n++);
      |                       ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | d[99999],a[20],i,j,k,n;
main.c:12:12: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
   12 |         i=!printf("%d",d[(1<<n)-1]);
      |            ^~~~~~
main.c:12:12: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
/usr/bin/ld: /tmp/ccThfcfl.o: in function `main':
main.c:(.text.startup+0x2c): 警告: the `gets' function is dangerous and should not be used.

ソースコード

diff #
raw source code

d[99999],a[20],i,j,k,n;
main(m){
	for(gets(&m);~scanf("%d",a+n);n++);
	for(;i<1<<n;i++){
		for(j=0;j<n;j++){
			if(i>>j&1)continue;
			for(m=k=0;k<n;k++)m=(m+(i>>k&1)*a[k])%1000;
			m=a[j]<m?0:a[j]-m;
			!d[i^1<<j]|d[i^1<<j]>d[i]+m?d[i^1<<j]=d[i]+m:0;
		}
	}
	i=!printf("%d",d[(1<<n)-1]);
}
0