結果

問題 No.158 奇妙なお使い
ユーザー yuustiyuusti
提出日時 2015-03-13 02:18:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 1,602 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 84,484 KB
実行使用メモリ 47,488 KB
最終ジャッジ日時 2023-09-11 08:14:27
合計ジャッジ時間 2,563 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
46,772 KB
testcase_01 AC 14 ms
46,748 KB
testcase_02 AC 13 ms
46,820 KB
testcase_03 AC 14 ms
46,784 KB
testcase_04 AC 29 ms
47,364 KB
testcase_05 AC 13 ms
46,788 KB
testcase_06 AC 13 ms
46,936 KB
testcase_07 AC 13 ms
46,880 KB
testcase_08 AC 13 ms
46,820 KB
testcase_09 AC 14 ms
46,756 KB
testcase_10 AC 14 ms
46,804 KB
testcase_11 AC 13 ms
46,800 KB
testcase_12 AC 14 ms
46,736 KB
testcase_13 AC 14 ms
47,020 KB
testcase_14 AC 14 ms
46,748 KB
testcase_15 AC 14 ms
46,744 KB
testcase_16 AC 14 ms
46,732 KB
testcase_17 AC 14 ms
46,800 KB
testcase_18 AC 17 ms
46,824 KB
testcase_19 AC 14 ms
46,760 KB
testcase_20 AC 13 ms
46,812 KB
testcase_21 AC 14 ms
47,488 KB
testcase_22 AC 14 ms
47,260 KB
testcase_23 AC 14 ms
46,808 KB
testcase_24 AC 14 ms
46,760 KB
testcase_25 AC 14 ms
46,744 KB
testcase_26 AC 13 ms
46,808 KB
testcase_27 AC 13 ms
46,740 KB
testcase_28 AC 14 ms
46,796 KB
testcase_29 AC 14 ms
46,884 KB
testcase_30 AC 14 ms
46,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>
#include <unordered_map>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;

int dp[11][101][10001];

int db, dc;
int b[3], c[3];

int f(int, int, int);

int check(int x, int y, int z, int cost, int *d){
	{
		int k = min(x, cost / 1000);
		cost -= k * 1000;
		x += d[0] - k;
	}
	{
		int k = min(y, cost / 100);
		cost -= k * 100;
		y += d[1] - k;
	}
	{
		int k = min(z, cost);
		cost -= k;
		z += d[2] - k;
	}
	return !cost ? 1 + f(x, y, z): 0;
}

int f(int x, int y, int z){
	int &res = dp[x][y][z];
	if (res + 1) return res;
	return res = max(check(x, y, z, db, b), check(x, y, z, dc, c));
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(20);

	MEMSET(dp, -1);

	int x, y, z;
	cin >> x >> y >> z;
	cin >> db;
	rep(i, 3) cin >> b[i];
	cin >> dc;
	rep(i, 3) cin >> c[i];

	cout << f(x, y, z) << endl;
}
0