結果
問題 |
No.1122 Plane Tickets
|
ユーザー |
![]() |
提出日時 | 2020-07-22 22:56:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,067 bytes |
コンパイル時間 | 1,283 ms |
コンパイル使用メモリ | 166,672 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 00:02:53 |
合計ジャッジ時間 | 2,571 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 12 WA * 43 |
ソースコード
#include <bits/stdc++.h> using namespace std; long long f(long long a, long long b, long long c, long long d, long long e){ long long d1 = d - c; long long d2 = d - e; long long ans = 0; long long x, y; x = a - d1 - (a + b - d1 - d2 + 1) / 2; y = b - d2 - (a + b - d1 - d2 + 1) / 2; if (x >= 0 && y >= 0 && x + d1 >= 0 && y + d2 >= 0 && x * 2 + y <= a - d1 && x + y * 2 <= b - d2){ ans = max(ans, x + y + d); } x = - d1; y = a + d1; if (x >= 0 && y >= 0 && x + d1 >= 0 && y + d2 >= 0 && x * 2 + y <= a - d1 && x + y * 2 <= b - d2){ ans = max(ans, x + y + d); } x = b + d2; y = - d2; if (x >= 0 && y >= 0 && x + d1 >= 0 && y + d2 >= 0 && x * 2 + y <= a - d1 && x + y * 2 <= b - d2){ ans = max(ans, x + y + d); } return ans; } int main(){ long long a, b, c, d, e; cin >> a >> b >> c >> d >> e; long long ans = 0; ans = max(ans, f(a, b, c, d, e)); ans = max(ans, f(b, c, d, e, a)); ans = max(ans, f(c, d, e, a, b)); ans = max(ans, f(d, e, a, b, c)); ans = max(ans, f(e, a, b, c, d)); cout << ans << endl; }