結果

問題 No.385 カップ麺生活
コンテスト
ユーザー ciel
提出日時 2018-02-12 00:06:51
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 305 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 103 ms
コンパイル使用メモリ 29,892 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-08 16:16:00
合計ジャッジ時間 1,102 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | T[10001],A[10001],B[99],k,r;main(){
      | ^
main.c: In function ‘main’:
main.c:3:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
    3 |         scanf("%d%d",&m,&n);
      |         ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | T[10001],A[10001],B[99],k,r;main(){
main.c:7:13: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
    7 |         *B=!printf("%lld\n",r+k);
      |             ^~~~~~
main.c:7:13: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:7:24: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int’ [-Wformat=]
    7 |         *B=!printf("%lld\n",r+k);
      |                     ~~~^    ~~~
      |                        |     |
      |                        |     int
      |                        long long int
      |                     %d

ソースコード

diff #
raw source code

T[10001],A[10001],B[99],k,r;main(){
	int m,n,i,j;
	scanf("%d%d",&m,&n);
	for(i=0;i<n;i++)scanf("%d",B+i),A[B[i]]=1;
	for(i=0;i<n;i++)for(j=0;j<=m-B[i];j++)if(A[j]&&A[j+B[i]]<=A[j])A[j+B[i]]=A[j]+1;
	for(i=2;i<=m;i++)if(k=k>A[i]?k:A[i],!T[i])for(r+=A[m-i],j=i;j<=m;j+=i)T[j]=1;
	*B=!printf("%lld\n",r+k);
}
0