結果

問題 No.393 2本の竹
コンテスト
ユーザー 👑 tails
提出日時 2016-07-12 20:43:39
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 903 ms / 1,000 ms
+ 883µs
コード長 583 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,007 ms
コンパイル使用メモリ 184,656 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2026-09-17 12:40:39
合計ジャッジ時間 5,189 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
			set<int>::iterator e=h.end();
			for(set<int>::iterator p=h.begin();p!=e;++p){
				int b=*p;
				if(s-b<=n2){
					z.insert(b);
				}
				if(b+a<=n1){
					z.insert(b+a);
				}
			}
			h.swap(z);
			if(h.empty()){
				break;
			}
			++n;
		}
		cout<<n<<endl;
	}
}
0