結果

問題 No.158 奇妙なお使い
ユーザー antaanta
提出日時 2015-02-26 23:46:20
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,369 bytes
コンパイル時間 569 ms
コンパイル使用メモリ 75,320 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 02:52:27
合計ジャッジ時間 33,848 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,002 ms
4,384 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1,002 ms
4,380 KB
testcase_06 AC 1,001 ms
4,380 KB
testcase_07 AC 1,001 ms
4,376 KB
testcase_08 AC 1,002 ms
4,380 KB
testcase_09 AC 1,002 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1,002 ms
4,376 KB
testcase_13 AC 1,002 ms
4,376 KB
testcase_14 AC 1,002 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 1,002 ms
4,380 KB
testcase_17 WA -
testcase_18 AC 1,002 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1,002 ms
4,384 KB
testcase_26 WA -
testcase_27 AC 1,002 ms
4,380 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0