結果

問題 No.846 メダル
ユーザー walk_to_workwalk_to_work
提出日時 2019-07-27 18:50:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,825 bytes
コンパイル時間 1,640 ms
コンパイル使用メモリ 163,212 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 10:10:16
合計ジャッジ時間 2,578 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

ll p,q,r,a,b,c;

bool check(ll i){
	ll x , y , z;
	x = floor( (long double)i / p );
	y = floor( (long double)i / q ) - a;
	z = floor( (long double)i / r ) - a - b;

	if( i % p ) x++;
	if( i % q ) y++;
	if( i % r ) z++;

	if( x == a &&  y == b &&  z == c ) ret true;
	ret false;
}

ll rr;

ll bef_l = INF , bef_c = INF , bef_r = INF;

ll s_l( ll l , ll c , ll r  ){
	//cout << l << " " << c << " " << r << endl;
	//cout << check(c-1) <<  check(c) <<  check(c+1) << endl;
	if(   !check(c-1) && check(c) && check(c+1)  ){
		ret c;
	}


	if( r <= l ) ret -2;
	if( c == bef_c && l == bef_l && r == bef_r ) ret -2;
	bef_c = c;
	bef_l = l;
	bef_r = r;

	if ( check(c) ){
		ll idx = (long double)(c-l)/2+l;
		ret s_l(l, idx ,c );
	}
	else{
		ll idx = (long double)(r-c)/2+c;
		ret s_l(c, idx ,r);
	}
}


int main(){
	cin >> p >> q >> r >> a >> b >> c;

	rr = min(p*a , min( (a+b)*q , (a+b+c)*r));

	ll l = s_l(0,rr/2,rr );

	if( l == -2 ){
		cout << -1 << endl;
		ret 0;
	}

	cout << l << " " << rr<< endl;


	ret 0;
}
0