結果

問題 No.158 奇妙なお使い
ユーザー antaanta
提出日時 2015-02-27 00:16:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,112 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 75,676 KB
実行使用メモリ 7,792 KB
最終ジャッジ日時 2023-09-06 03:00:46
合計ジャッジ時間 7,202 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 TLE -
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 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int A[3], D[2], B[2][3];
	rep(k, 3) cin >> A[k];
	rep(i, 2) {
		cin >> D[i];
		rep(k, 3) cin >> B[i][k];
	}
	int l = 0, u = 10000;
	while(u - l > 0) {
		int mid = (l + u + 1) / 2;
		bool ok = false;
		rer(cnt0, 0, mid) {
			int cnt1 = mid - cnt0;
			int cnts[2] = { cnt0, mid - cnt0 };
			int a[3] = { A[0], A[1], A[2] };
			while(1) {
				bool okok = false;
				rep(i, 2) if(cnts[i] > 0) {
					int d = D[i];
					{	int t = min(a[0], d / 1000);
						d -= t * 1000, a[0] -= t;
					}
					{	int t = min(a[1], d / 100);
						d -= t * 100, a[1] -= t;
					}
					{	int t = min(a[2], d / 1);
						d -= t * 1, a[2] -= t;
					}
					if(d != 0)
						continue;
					a[0] += B[i][0];
					a[1] += B[i][1];
					a[2] += B[i][2];
					-- cnts[i];
					okok = true;
					break;
				}
				if(!okok) break;
			}
			ok |= cnts[0] == 0 && cnts[1] == 0;
		}
		if(ok)
			l = mid;
		else
			u = mid - 1;
	}
	printf("%d\n", l);
	return 0;
}
0