結果
問題 | No.158 奇妙なお使い |
ユーザー | kei |
提出日時 | 2018-08-27 21:23:35 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,889 ms / 5,000 ms |
コード長 | 3,036 bytes |
コンパイル時間 | 1,707 ms |
コンパイル使用メモリ | 174,280 KB |
実行使用メモリ | 90,352 KB |
最終ジャッジ日時 | 2024-07-01 04:12:11 |
合計ジャッジ時間 | 45,931 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,323 ms
90,308 KB |
testcase_01 | AC | 1,329 ms
90,216 KB |
testcase_02 | AC | 1,324 ms
90,304 KB |
testcase_03 | AC | 1,327 ms
90,108 KB |
testcase_04 | AC | 1,889 ms
90,112 KB |
testcase_05 | AC | 1,310 ms
90,176 KB |
testcase_06 | AC | 1,306 ms
90,284 KB |
testcase_07 | AC | 1,316 ms
90,192 KB |
testcase_08 | AC | 1,328 ms
90,340 KB |
testcase_09 | AC | 1,327 ms
90,220 KB |
testcase_10 | AC | 1,319 ms
90,240 KB |
testcase_11 | AC | 1,344 ms
90,156 KB |
testcase_12 | AC | 1,330 ms
90,244 KB |
testcase_13 | AC | 1,323 ms
90,108 KB |
testcase_14 | AC | 1,329 ms
90,224 KB |
testcase_15 | AC | 1,336 ms
90,188 KB |
testcase_16 | AC | 1,330 ms
90,264 KB |
testcase_17 | AC | 1,356 ms
90,116 KB |
testcase_18 | AC | 1,397 ms
90,336 KB |
testcase_19 | AC | 1,318 ms
90,248 KB |
testcase_20 | AC | 1,317 ms
90,132 KB |
testcase_21 | AC | 1,327 ms
90,188 KB |
testcase_22 | AC | 1,332 ms
90,332 KB |
testcase_23 | AC | 1,328 ms
90,236 KB |
testcase_24 | AC | 1,317 ms
90,340 KB |
testcase_25 | AC | 1,322 ms
90,120 KB |
testcase_26 | AC | 1,317 ms
90,244 KB |
testcase_27 | AC | 1,315 ms
90,232 KB |
testcase_28 | AC | 1,336 ms
90,352 KB |
testcase_29 | AC | 1,327 ms
90,176 KB |
testcase_30 | AC | 1,326 ms
90,188 KB |
ソースコード
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; } template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; } template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; } template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; } /* <url:https://yukicoder.me/problems/no/158> 問題文============================================================ ================================================================= 解説============================================================= ================================================================ */ ll dp[11][101][10001]; tuple<int,int,int> can_pay(int i,int j,int k,int D){ int t; t = min(i,D/1000); i -= t; D -= t*1000; t = min(j,D/100); j -= t; D -= t*100; t = min(k,D); k -= t; D -= t; if(D) return tuple<int,int,int>{-1,-1,-1}; return tuple<int,int,int>{i,j,k}; } ll solve(){ fill(**dp,**dp+11*101*10001,-1); ll res = 0; vector<ll> A(3),B(3),C(3); int Db,Dc; for(auto& in:A) cin >> in; cin >> Db; for(auto& in:B) cin >> in; cin >> Dc; for(auto& in:C) cin >> in; dp[A[0]][A[1]][A[2]] = 0; for(int kassa = 0; kassa < 100; kassa++){ 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] == -1) continue; { int ni,nj,nk; tie(ni,nj,nk) = can_pay(i, j, k, Db); if(ni != -1){ dp[ni+B[0]][nj+B[1]][nk+B[2]] = max(dp[ni+B[0]][nj+B[1]][nk+B[2]],dp[i][j][k]+1); } } { int ni,nj,nk; tie(ni,nj,nk) = can_pay(i, j, k, Dc); if(ni != -1){ dp[ni+C[0]][nj+C[1]][nk+C[2]] = max(dp[ni+C[0]][nj+C[1]][nk+C[2]],dp[i][j][k]+1); } } } } } } for(int i = 10; i >= 0; i--){ for(int j = 100; j >= 0; j--){ for(int k = 10000; k >= 0; k--){ res = max(res,dp[i][j][k]); } } } return res; } int main(void) { cin.tie(0); ios_base::sync_with_stdio(false); cout << solve() << endl; return 0; }