結果

問題 No.393 2本の竹
ユーザー kurenai3110kurenai3110
提出日時 2016-07-12 01:26:46
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,103 bytes
コンパイル時間 906 ms
コンパイル使用メモリ 75,432 KB
実行使用メモリ 814,468 KB
最終ジャッジ日時 2024-04-23 01:46:35
合計ジャッジ時間 4,715 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

bool dp1[100010];
bool dp2[100010];

int solve(vector<int> &a, vector<pair<int, int> > bb, int cnt);

int main()
{
	int d,bb1,bb2,m;


	cin >> d;
	for (int i = 0; i < d; i++) {
		int cnt=0;
		cin >> bb1 >> bb2 >> m;
		vector<pair<int, int> > bamboo;
		bamboo.push_back(make_pair(bb1, bb2));
		vector<int> a;
		a.resize(m);
		for (int j = 0; j < m; j++) {
			cin >> a[j];
		}
		sort(a.begin(), a.end());

		cnt = solve(a, bamboo, cnt);
		cout << cnt-1 << endl;
	}

    return 0;
}

int solve(vector<int> &a,vector<pair<int,int> > bb, int cnt) {
	vector<pair<int,int> > bbtmp;
	for (int i = 0; i < bb.size(); i++) {
		if (bb[i].first >= a.front()) {
			bbtmp.push_back(make_pair(bb[i].first - a.front(), bb[i].second));
		}
		if (bb[i].second >= a.front()) {
			bbtmp.push_back(make_pair(bb[i].first, bb[i].second - a.front()));
		}
	}
	a.erase(a.begin());

	cnt++;
	if (bbtmp.size()) {
		if (a.size()) {
			cnt = solve(a, bbtmp, cnt);
		}
		else {
			return ++cnt;
		}
	}

	return cnt;
}


0