結果
| 問題 | No.1122 Plane Tickets |
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2020-07-22 23:23:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 397 ms / 1,000 ms |
| コード長 | 1,859 bytes |
| 記録 | |
| コンパイル時間 | 1,324 ms |
| コンパイル使用メモリ | 127,660 KB |
| 最終ジャッジ日時 | 2025-01-12 03:52:45 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 55 |
ソースコード
#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;
}
chocorusk