結果

問題 No.1947 質より種類数
ユーザー tailstails
提出日時 2022-05-20 22:16:14
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 381 bytes
コンパイル時間 1,344 ms
コンパイル使用メモリ 29,144 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 12:59:26
合計ジャッジ時間 3,155 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 19 ms
4,348 KB
testcase_15 AC 10 ms
4,348 KB
testcase_16 AC 27 ms
4,348 KB
testcase_17 AC 34 ms
4,348 KB
testcase_18 AC 61 ms
4,348 KB
testcase_19 AC 53 ms
4,348 KB
testcase_20 AC 40 ms
4,348 KB
testcase_21 AC 47 ms
4,348 KB
testcase_22 AC 3 ms
4,348 KB
testcase_23 AC 22 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 63 ms
4,348 KB
testcase_30 AC 73 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 1 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 74 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:4:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    4 |         scanf("%ld%ld%ld",&n,&t,&c);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | long d[5001];
main.c:4:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    4 |         scanf("%ld%ld%ld",&n,&t,&c);
      |         ^~~~~
main.c:4:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:25:9: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   25 |         printf("%ld",z);
      |         ^~~~~~
main.c:25:9: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:25:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:25:9: note: include '<stdio.h>' or provide a declaration of 'printf'

ソースコード

diff #

long d[5001];
int main(){
	long n,t,c;
	scanf("%ld%ld%ld",&n,&t,&c);
	for(long i=0;i<n;++i){
		long v,w;
		scanf("%ld%ld",&v,&w);
		for(long j=0;j<=t-v;++j){
			if(d[j]<d[j+v]+w+c){
				d[j]=d[j+v]+w+c;
			}
		}
		for(long j=t-v;j>=0;--j){
			if(d[j]<d[j+v]+w){
				d[j]=d[j+v]+w;
			}
		}
	}
	long z=0;
	for(long j=0;j<=t;++j){
		if(z<d[j]){
			z=d[j];
		}
	}
	printf("%ld",z);
}
0