結果

問題 No.1122 Plane Tickets
ユーザー pockyny
提出日時 2020-07-23 00:25:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 798 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 79,800 KB
最終ジャッジ日時 2025-01-12 04:02:25
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12 WA * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
ll minf = -10000000000;
ll solve(vector<ll> &v){
    ll a = v[0],b = v[1],c = v[2],d = v[3],e = v[4];
    ll x = max({a + c - d - b,c - d,a + c - e - min(b,c),(2*a + 2*c - b - d - e)/3,0LL});
    ll y = min({a,b,c,min(b,c) - (b - a)});
    if(a==0 && b==0 && c==2935){
        //cout << d << " " << e << " " << x << " " << y << endl;
    }
    if(x<=y){
        return a + c - x;
    }else{
        return minf;
    }
}

int main(){
    vector<ll> v;
    int i;
    for(i=0;i<5;i++){
        ll a; cin >> a; v.push_back(a);
    }
    sort(v.begin(),v.end());
    ll ans = solve(v);
    while(next_permutation(v.begin(),v.end())){
        ans = max(ans,solve(v));
    }
    cout << ans << endl;
}
0