結果
| 問題 |
No.158 奇妙なお使い
|
| コンテスト | |
| ユーザー |
IL_msta
|
| 提出日時 | 2017-02-28 23:13:07 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 3,173 bytes |
| コンパイル時間 | 2,505 ms |
| コンパイル使用メモリ | 120,892 KB |
| 実行使用メモリ | 56,064 KB |
| 最終ジャッジ日時 | 2024-06-12 00:38:38 |
| 合計ジャッジ時間 | 13,317 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 TLE * 1 -- * 13 |
ソースコード
#pragma region GNUC
//以下を参考にした
//https://yukicoder.me/wiki/auto_vectorization
#ifdef __GNUC__
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#endif
#pragma endregion
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <valarray>
//#include <array>//x C++ (G++ 4.6.4)
#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>
#include <cassert>//assert();
#include <fstream>
#include <random>
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#define PII pair<int,int>
/////////
using namespace::std;
// 最大公約数
template<class T>
inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;}
//inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);}
// 最小公倍数
template<class T>
inline T lcm(T a, T b){return a / gcd(a, b) * b;}
//inline T lcm(T a, T b){return a * b / gcd(a, b);}
////////////////////////////////
struct mon{
int A,B,C;
};
bool operator<(mon m1,mon m2){
if( m1.A<m2.A)return true;
else if(m1.A>m2.A)return false;
if( m1.B<m2.B)return true;
else if(m1.B>m2.B)return false;
if( m1.C<m2.C)return true;
else if(m1.C>m2.C)return false;
return false;
}
int eval(mon m){
return m.A*1000+m.B*100+m.C;
}
mon pay(mon m,int D){
mon ret;
int temp = min(m.A,D/1000);
if( temp < 0 ){
mon ans={-1,-1,1};
return ans;
}
ret.A = m.A - temp;
D -= 1000*temp;
temp = min(m.B,D/100);
if( temp < 0 ){
mon ans={-1,-1,1};
return ans;
}
ret.B = m.B - temp;
D -= 100 * temp;
if( m.C < D ){
mon ans={-1,-1,1};
return ans;
}
ret.C = m.C - D;
return ret;
}
void solve(){
vector< vector< vector<int> > > dp(11,vector< vector<int> >(101,vector<int>(10001,-1)) );
mon start;
cin >> start.A >> start.B >> start.C;
dp[start.A][start.B][start.C] = 0;
int D[2];
mon P[2];
for(int i=0;i<2;++i){
cin >> D[i];
cin >> P[i].A >> P[i].B >> P[i].C;
}
int ans = 0;
for(int i=10;i>=0;--i){
for(int j=100;j>=0;--j){
for(int k=10000;k>=0;--k){
if( dp[i][j][k] < 0 ) continue;
for(int p=0;p<2;++p){
mon now={i,j,k};
if( D[p] > eval(now) ) continue;
mon next = pay(now,D[p]);
if( next.A < 0 || next.B <0 || next.C < 0 ) continue;
next.A += P[p].A;
next.B += P[p].B;
next.C += P[p].C;
int nowVal = dp[i][j][k];
int nextVal = dp[next.A][next.B][next.C];
if( nextVal < nowVal+1 ){
dp[next.A][next.B][next.C] = nowVal+1;
if( ans < nowVal+1 ) ans = nowVal+1;
cerr << next.A << " " << next.B << " " << next.C << endl;
if( (i < next.A) ||
( i == next.A && j < next.B )||
( i == next.A && j == next.B && k < next.C )
)
{
i = next.A;
j = next.B;
k = next.C+1;
}
}
}
}}}
cout << ans << endl;
}
signed main(void){
std::cin.tie(0);
std::ios::sync_with_stdio(false);
//std::cout << std::fixed;//小数を10進数表示
//cout << setprecision(16);//小数点以下の桁数を指定
solve();
}
IL_msta