結果
| 問題 |
No.158 奇妙なお使い
|
| コンテスト | |
| ユーザー |
kmjp
|
| 提出日時 | 2015-02-27 02:24:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 801 ms / 5,000 ms |
| コード長 | 1,422 bytes |
| コンパイル時間 | 1,640 ms |
| コンパイル使用メモリ | 177,520 KB |
| 実行使用メモリ | 59,520 KB |
| 最終ジャッジ日時 | 2024-06-28 22:24:05 |
| 合計ジャッジ時間 | 3,618 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int A[3],B[2][3];
int D[2];
int ma;
typedef tuple<int,int,int> S;
set<S> V[10001];
map<S,int> M;
int val(S v){ return get<0>(v)*1000+get<1>(v)*100+get<2>(v);}
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>A[0]>>A[1]>>A[2];
FOR(i,2) cin>>D[i]>>B[i][0]>>B[i][1]>>B[i][2];
S f = tie(A[0],A[1],A[2]);
M[f]=0;
V[val(f)].insert(f);
for(i=10000;i>=0;i--) {
ITR(it,V[i]) {
ma=max(ma,M[*it]);
FOR(j,2) {
S k=*it;
x=D[j];
r=min(x/1000,get<0>(k)); x -= r*1000; get<0>(k)-=r;
r=min(x/100,get<1>(k)); x -= r*100 ; get<1>(k)-=r;
r=min(x,get<2>(k)); x -= r; get<2>(k)-=r;
if(x==0) {
get<0>(k) += B[j][0];
get<1>(k) += B[j][1];
get<2>(k) += B[j][2];
M[k]=max(M[k],M[*it]+1);
V[val(k)].insert(k);
}
}
}
}
cout<<ma<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false);
FOR(i,argc-1) s+=argv[i+1],s+='\n';
FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
solve(); return 0;
}
kmjp