結果

問題 No.1122 Plane Tickets
ユーザー chocoruskchocorusk
提出日時 2020-07-22 23:23:58
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 367 ms / 1,000 ms
コード長 1,859 bytes
コンパイル時間 1,326 ms
コンパイル使用メモリ 131,912 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 22:16:30
合計ジャッジ時間 21,955 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 232 ms
4,380 KB
testcase_01 AC 236 ms
4,380 KB
testcase_02 AC 234 ms
4,376 KB
testcase_03 AC 229 ms
4,376 KB
testcase_04 AC 245 ms
4,376 KB
testcase_05 AC 246 ms
4,380 KB
testcase_06 AC 259 ms
4,380 KB
testcase_07 AC 262 ms
4,376 KB
testcase_08 AC 362 ms
4,376 KB
testcase_09 AC 349 ms
4,376 KB
testcase_10 AC 353 ms
4,376 KB
testcase_11 AC 348 ms
4,376 KB
testcase_12 AC 349 ms
4,380 KB
testcase_13 AC 357 ms
4,376 KB
testcase_14 AC 361 ms
4,376 KB
testcase_15 AC 355 ms
4,376 KB
testcase_16 AC 363 ms
4,380 KB
testcase_17 AC 356 ms
4,380 KB
testcase_18 AC 356 ms
4,376 KB
testcase_19 AC 345 ms
4,384 KB
testcase_20 AC 350 ms
4,376 KB
testcase_21 AC 353 ms
4,376 KB
testcase_22 AC 335 ms
4,380 KB
testcase_23 AC 352 ms
4,380 KB
testcase_24 AC 356 ms
4,376 KB
testcase_25 AC 358 ms
4,376 KB
testcase_26 AC 355 ms
4,380 KB
testcase_27 AC 360 ms
4,376 KB
testcase_28 AC 332 ms
4,376 KB
testcase_29 AC 356 ms
4,376 KB
testcase_30 AC 344 ms
4,380 KB
testcase_31 AC 340 ms
4,380 KB
testcase_32 AC 337 ms
4,380 KB
testcase_33 AC 359 ms
4,376 KB
testcase_34 AC 338 ms
4,380 KB
testcase_35 AC 337 ms
4,380 KB
testcase_36 AC 320 ms
4,380 KB
testcase_37 AC 338 ms
4,376 KB
testcase_38 AC 336 ms
4,376 KB
testcase_39 AC 318 ms
4,380 KB
testcase_40 AC 324 ms
4,376 KB
testcase_41 AC 341 ms
4,380 KB
testcase_42 AC 296 ms
4,376 KB
testcase_43 AC 316 ms
4,376 KB
testcase_44 AC 297 ms
4,380 KB
testcase_45 AC 301 ms
4,376 KB
testcase_46 AC 299 ms
4,380 KB
testcase_47 AC 301 ms
4,376 KB
testcase_48 AC 266 ms
4,380 KB
testcase_49 AC 314 ms
4,380 KB
testcase_50 AC 207 ms
4,376 KB
testcase_51 AC 349 ms
4,380 KB
testcase_52 AC 359 ms
4,376 KB
testcase_53 AC 367 ms
4,380 KB
testcase_54 AC 358 ms
4,376 KB
testcase_55 AC 357 ms
4,380 KB
testcase_56 AC 349 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
struct R{
    ll x, y;
    R(ll a, ll b){
        ll g=gcd(a, b);
        x=a/g, y=b/g;
    }
    R(ll a):x(a), y(1){}
    R():x(0), y(1){}
    R operator+(R r){
        return R(x*r.y+y*r.x, y*r.y);
    }
    R operator-(R r){
        return R(x*r.y-y*r.x, y*r.y);
    }
    R operator*(R r){
        return R(x*r.x, y*r.y);
    }
    R operator/(R r){
        return R(x*r.y, y*r.x);
    }
    bool operator==(const R &r)const{
        return x==r.x && y==r.y;
    }
    bool operator<(const R &r)const{
        return x*r.y<y*r.x;
    }
};
int main()
{
	ll a[5];
	for(int i=0; i<5; i++) cin>>a[i];
	vector<R> v;
	for(int i=1; i<=6; i++){
		for(int j=0; j<=i; j++){
			if(gcd(i, j)>1) continue;
			v.push_back(R(j, i));
		}
	}
	int m=v.size();
	int i[5];
	ll ans=1e18;
	for(i[0]=0; i[0]<m; i[0]++){
		for(i[1]=0; i[1]<m; i[1]++){
			for(i[2]=0; i[2]<m; i[2]++){
				for(i[3]=0; i[3]<m; i[3]++){
					for(i[4]=0; i[4]<m; i[4]++){
						bool dame=0;
						for(int j=0; j<5; j++){
							R s(0);
							for(int k=0; k<3; k++){
								s=s+v[i[(j+k)%5]];
							}
							if(s<R(1)){
								dame=1;break;
							}
						}
						if(dame) continue;
						R sum(0);
						for(int j=0; j<5; j++){
							sum=sum+v[i[j]]*R(a[j]);
						}
						ans=min(ans, sum.x/sum.y);
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
0