結果
問題 | No.158 奇妙なお使い |
ユーザー | yuusti |
提出日時 | 2015-03-13 02:18:32 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 57 ms / 5,000 ms |
コード長 | 1,602 bytes |
コンパイル時間 | 645 ms |
コンパイル使用メモリ | 83,872 KB |
実行使用メモリ | 47,616 KB |
最終ジャッジ日時 | 2024-06-28 22:47:22 |
合計ジャッジ時間 | 2,774 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 27 |
ソースコード
#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; }