結果
問題 |
No.158 奇妙なお使い
|
ユーザー |
![]() |
提出日時 | 2015-02-26 23:46:20 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,369 bytes |
コンパイル時間 | 819 ms |
コンパイル使用メモリ | 81,716 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 21:45:17 |
合計ジャッジ時間 | 33,861 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 9 WA * 18 |
ソースコード
#include <string> #include <vector> #include <algorithm> #include <numeric> #include <set> #include <map> #include <queue> #include <iostream> #include <sstream> #include <cstdio> #include <cmath> #include <ctime> #include <cstring> #include <cctype> #include <cassert> #include <limits> #include <functional> #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) #if defined(_MSC_VER) || __cplusplus > 199711L #define aut(r,v) auto r = (v) #else #define aut(r,v) __typeof(v) r = (v) #endif #define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it) #define all(o) (o).begin(), (o).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset(m,v,sizeof(m)) #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL using namespace std; typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll; template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; } template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; } #ifdef WIN32 extern "C" int __stdcall QueryPerformanceFrequency(long long*); extern "C" int __stdcall QueryPerformanceCounter(long long*); double getTime() { long long c, freq; QueryPerformanceCounter(&c); QueryPerformanceFrequency(&freq); return c * 1. / freq; } #else #include <sys/time.h> double getTime() { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec + tv.tv_usec / 1e6; } #endif int main() { int A[3], D[2], B[2][3]; rep(k, 3) cin >> A[k]; rep(i, 2) { cin >> D[i]; rep(k, 3) cin >> B[i][k]; } double st = getTime(); int ans = 0; while(getTime() - st <= 1) { int a[3] = { A[0], A[1], A[2] }; int cnt = 0; while(1) { int s = (rand() >> 10) % 2; bool ok = false; rep(ii, 2) { int i = s ^ ii; int d = D[i]; { int t = min(a[0], d / 1000); d -= t * 1000, a[0] -= t; } { int t = min(a[1], d / 100); d -= t * 100, a[1] -= t; } { int t = min(a[2], d / 1); d -= t * 1, a[2] -= t; } if(d != 0) { continue; } a[0] += B[i][0]; a[1] += B[i][1]; a[2] += B[i][2]; ++ cnt; ok = true; break; } if(!ok) break; } amax(ans, cnt); } printf("%d\n", ans); return 0; }