結果

問題 No.158 奇妙なお使い
ユーザー antaanta
提出日時 2015-02-26 23:54:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 2,213 bytes
コンパイル時間 665 ms
コンパイル使用メモリ 82,548 KB
実行使用メモリ 50,832 KB
最終ジャッジ日時 2023-09-11 07:52:04
合計ジャッジ時間 3,257 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
50,632 KB
testcase_01 AC 41 ms
50,468 KB
testcase_02 AC 42 ms
50,528 KB
testcase_03 AC 41 ms
50,676 KB
testcase_04 AC 48 ms
50,532 KB
testcase_05 AC 41 ms
50,468 KB
testcase_06 AC 43 ms
50,832 KB
testcase_07 AC 43 ms
50,632 KB
testcase_08 AC 42 ms
50,516 KB
testcase_09 AC 42 ms
50,552 KB
testcase_10 AC 43 ms
50,548 KB
testcase_11 AC 43 ms
50,476 KB
testcase_12 AC 43 ms
50,528 KB
testcase_13 AC 42 ms
50,472 KB
testcase_14 AC 42 ms
50,560 KB
testcase_15 AC 42 ms
50,516 KB
testcase_16 AC 43 ms
50,528 KB
testcase_17 AC 43 ms
50,576 KB
testcase_18 AC 44 ms
50,532 KB
testcase_19 AC 42 ms
50,520 KB
testcase_20 AC 42 ms
50,584 KB
testcase_21 AC 43 ms
50,672 KB
testcase_22 AC 43 ms
50,520 KB
testcase_23 AC 42 ms
50,684 KB
testcase_24 AC 43 ms
50,520 KB
testcase_25 AC 43 ms
50,572 KB
testcase_26 AC 43 ms
50,468 KB
testcase_27 AC 43 ms
50,552 KB
testcase_28 AC 44 ms
50,532 KB
testcase_29 AC 44 ms
50,580 KB
testcase_30 AC 44 ms
50,512 KB
権限があれば一括ダウンロードができます

ソースコード

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];
	}
	vector<vector<vector<int> > > dp(11, vector<vector<int> >(101, vector<int>(10001, -1)));
	dp[A[0]][A[1]][A[2]] = 0;
	int ans = 0;
	for(int t = 10000; t >= 0; -- t) {
		int m0 = t / 1000;
		rer(a0, 0, m0) {
			int m1 = (t - a0 * 1000) / 100;
			rer(a1, 0, m1) {
				int a2 = t - a0 * 1000 - a1 * 100;
				int x = dp[a0][a1][a2];
				if(x == -1) continue;
//				cerr << t << ", " << a0 << ", " << a1 << ", " << a2 << ": " << x << endl;
				amax(ans, x);
				rep(i, 2) {
					int a0t = a0, a1t = a1, a2t = a2;
					int d = D[i];
					{	int t = min(a0t, d / 1000);
						d -= t * 1000, a0t -= t;
					}
					{	int t = min(a1t, d / 100);
						d -= t * 100, a1t -= t;
					}
					{	int t = min(a2t, d / 1);
						d -= t * 1, a2t -= t;
					}
					if(d == 0) {
						a0t += B[i][0];
						a1t += B[i][1];
						a2t += B[i][2];
						amax(dp[a0t][a1t][a2t], x + 1);
					}
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}
0