結果
| 問題 |
No.158 奇妙なお使い
|
| コンテスト | |
| ユーザー |
sugim48
|
| 提出日時 | 2015-02-26 23:45:12 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 5,000 ms |
| コード長 | 1,601 bytes |
| コンパイル時間 | 631 ms |
| コンパイル使用メモリ | 85,904 KB |
| 実行使用メモリ | 13,184 KB |
| 最終ジャッジ日時 | 2024-06-28 22:20:53 |
| 合計ジャッジ時間 | 2,680 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
ソースコード
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <fstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { ll B, T, F, P; };
unsigned MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int UNKO = INT_MAX;
int dp[11][101][10001];
int main() {
int a4, a3, a1;
cin >> a4 >> a3 >> a1;
int Db; cin >> Db;
int b4, b3, b1;
cin >> b4 >> b3 >> b1;
int Dc; cin >> Dc;
int c4, c3, c1;
cin >> c4 >> c3 >> c1;
for (int y = 0; y <= 10000; y++)
for (int i = 0; i <= 10; i++)
for (int j = 0; j <= 100; j++) {
int k = y - i * 1000 - j * 100;
if (k < 0) continue;
int& x = dp[i][j][k];
int _Db = Db;
int B4 = min(i, _Db / 1000); _Db -= B4 * 1000;
int B3 = min(j, _Db / 100); _Db -= B3 * 100;
int B1 = min(k, _Db / 1); _Db -= B1 * 1;
if (!_Db) x = max(x, dp[i - B4 + b4][j - B3 + b3][k - B1 + b1] + 1);
int _Dc = Dc;
int C4 = min(i, _Dc / 1000); _Dc -= C4 * 1000;
int C3 = min(j, _Dc / 100); _Dc -= C3 * 100;
int C1 = min(k, _Dc / 1); _Dc -= C1 * 1;
if (!_Dc) x = max(x, dp[i - C4 + c4][j - C3 + c3][k - C1 + c1] + 1);
}
cout << dp[a4][a3][a1] << endl;
}
sugim48