結果

問題 No.393 2本の竹
ユーザー kotatsugamekotatsugame
提出日時 2020-03-04 08:16:19
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 63 ms / 1,000 ms
コード長 577 bytes
コンパイル時間 631 ms
使用メモリ 3,544 KB
最終ジャッジ日時 2022-12-07 18:30:47
合計ジャッジ時間 2,576 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
3,428 KB
testcase_01 AC 2 ms
3,536 KB
testcase_02 AC 1 ms
3,528 KB
testcase_03 AC 2 ms
3,476 KB
testcase_04 AC 2 ms
3,524 KB
testcase_05 AC 2 ms
3,376 KB
testcase_06 AC 1 ms
3,372 KB
testcase_07 AC 2 ms
3,380 KB
testcase_08 AC 2 ms
3,500 KB
testcase_09 AC 63 ms
3,500 KB
testcase_10 AC 11 ms
3,540 KB
testcase_11 AC 21 ms
3,452 KB
testcase_12 AC 26 ms
3,464 KB
testcase_13 AC 14 ms
3,544 KB
testcase_14 AC 9 ms
3,432 KB
testcase_15 AC 2 ms
3,452 KB
testcase_16 AC 5 ms
3,396 KB
testcase_17 AC 2 ms
3,540 KB
testcase_18 AC 2 ms
3,528 KB
testcase_19 AC 1 ms
3,452 KB
testcase_20 AC 1 ms
3,504 KB
testcase_21 AC 2 ms
3,452 KB
testcase_22 AC 32 ms
3,452 KB
testcase_23 AC 12 ms
3,488 KB
testcase_24 AC 2 ms
3,372 KB
testcase_25 AC 2 ms
3,524 KB
testcase_26 AC 2 ms
3,372 KB
testcase_27 AC 57 ms
3,492 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int d;
main()
{
	cin>>d;
	for(;d--;)
	{
		int N1,N2;cin>>N1>>N2;
		int M;cin>>M;
		vector<int>A(M);
		for(int i=0;i<M;i++)cin>>A[i];
		sort(A.begin(),A.end());
		vector<bool>dp(N1+1,false);
		dp[0]=true;
		int sum=0;
		int ans=0;
		for(int a:A)
		{
			sum+=a;
			int now=0;
			for(int i=N1;i>=0;i--)
			{
				if(dp[i])
				{
					now=max(now,i);
					if(i+a<=N1)
					{
						dp[i+a]=true;
						now=max(now,i+a);
					}
				}
			}
			if(sum-now<=N2)ans++;
			else break;
		}
		cout<<ans<<endl;
	}
}
0