結果

問題 No.393 2本の竹
ユーザー tailstails
提出日時 2016-07-12 17:33:02
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 546 bytes
コンパイル時間 1,616 ms
コンパイル使用メモリ 168,428 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-04-23 01:51:30
合計ジャッジ時間 6,451 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 5 ms
5,376 KB
testcase_08 AC 10 ms
5,376 KB
testcase_09 TLE -
testcase_10 AC 17 ms
5,376 KB
testcase_11 AC 224 ms
7,680 KB
testcase_12 AC 375 ms
7,936 KB
testcase_13 AC 114 ms
5,504 KB
testcase_14 AC 27 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 6 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 545 ms
9,856 KB
testcase_23 AC 58 ms
6,400 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
	int d;
	cin>>d;
	for(int i=0;i<d;++i){
		int n1,n2,m;
		cin>>n1>>n2>>m;
		int n=0;
		int s=0;
		set<int> h;
		h.insert(0);
		int v[60];
		for(int j=0;j<m;++j){
			cin>>v[j];
		}
		sort(v,v+m);

		for(int j=0;j<m;++j){
			int a=v[j];
			s+=a;
			set<int> z;
			for(set<int>::iterator p=h.begin();p!=h.end();++p){
				if(s-*p<=n2){
					z.insert(*p);
				}
				if(*p+a<=n1){
					z.insert(*p+a);
				}
			}
			h.swap(z);
			if(h.empty()){
				break;
			}
			++n;
		}
		cout<<n<<endl;
	}
}
0