結果

問題 No.158 奇妙なお使い
ユーザー 古寺いろは古寺いろは
提出日時 2015-04-14 00:49:41
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,589 bytes
コンパイル時間 1,225 ms
コンパイル使用メモリ 154,944 KB
実行使用メモリ 31,232 KB
最終ジャッジ日時 2023-09-17 20:04:55
合計ジャッジ時間 2,895 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 383 ms
31,232 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 WA -
testcase_18 AC 41 ms
7,396 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


int A[3], B[3], C[3];
int now[3];
int DB, DC;

bool useB(){
	int nokori = DB;
	int use0 = min(now[0], nokori / 1000);
	nokori -= use0 * 1000;
	int use1 = min(now[1], nokori / 100);
	nokori -= use1 * 100;
	int use2 = min(now[2], nokori / 1);
	nokori -= use2 * 1;
	if (nokori != 0) return false;
	now[0] += B[0] - use0;
	now[1] += B[1] - use1;
	now[2] += B[2] - use2;
	return true;
}

bool useC(){
	int nokori = DC;
	int use0 = min(now[0], nokori / 1000);
	nokori -= use0 * 1000;
	int use1 = min(now[1], nokori / 100);
	nokori -= use1 * 100;
	int use2 = min(now[2], nokori / 1);
	nokori -= use2 * 1;
	if (nokori != 0) return false;
	now[0] += C[0] - use0;
	now[1] += C[1] - use1;
	now[2] += C[2] - use2;
	return true;
}

int main() {
	cin >> A[0] >> A[1] >> A[2];
	cin >> DB;
	cin >> B[0] >> B[1] >> B[2];
	cin >> DC;
	cin >> C[0] >> C[1] >> C[2];

	set<tuple<int, int, int>> s, all;
	int ans = -1;
	auto first = make_tuple(A[0], A[1], A[2]);

	s.insert(first);
	all.insert(first);

	while (s.size()){
		ans++;
		set<tuple<int, int, int>> ns;
		for (auto i : s){
			now[0] = get<0>(i);
			now[1] = get<1>(i);
			now[2] = get<2>(i);
			if (useB()){
				auto n = make_tuple(now[0], now[1], now[2]);
				if (all.count(n) == 0){
					ns.insert(n);
					all.insert(n);
				}
				now[0] = get<0>(i);
				now[1] = get<1>(i);
				now[2] = get<2>(i);
			}
			if (useC()){
				auto n = make_tuple(now[0], now[1], now[2]);
				if (all.count(n) == 0){
					ns.insert(n);
					all.insert(n);
				}
			}
		}
		s = ns;
	}
	cout << ans << endl;
	cin >> ans;
}
0