結果

問題 No.1122 Plane Tickets
ユーザー risujirohrisujiroh
提出日時 2020-07-22 22:48:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 953 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 200,256 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 02:59:53
合計ジャッジ時間 4,384 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 WA -
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 WA -
testcase_50 AC 1 ms
4,376 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  using ll = long long;
  auto ts = [](ll l, ll r, auto f) {
    while (r - l > 2) {
      ll m = (l + r) / 2;
      if (f(m) < f(m + 1)) {
        l = m;
      } else {
        r = m + 1;
      }
    }
    return f(l + 1);
  };
  ll a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  auto g = [&](ll abe) {
    a -= abe;
    b -= abe;
    e -= abe;
    ll abc = min({a, b, c});
    ll cde = min({c - abc, d, e});
    ll bcd = min({b - abc, c - abc - cde, d - cde});
    a += abe;
    b += abe;
    e += abe;
    return abe + abc + bcd + cde;
  };
  auto f = [&](ll ade) {
    a -= ade;
    d -= ade;
    e -= ade;
    ll res = ts(-1, min({a, b, e}) + 1, g);
    a += ade;
    d += ade;
    e += ade;
    return ade + res;
  };
  cout << ts(-1, min({a, d, e}) + 1, f) << '\n';
}
0