結果

問題 No.859 路線A、路線B、路線C
ユーザー 0w10w1
提出日時 2020-11-15 01:32:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 619 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 198,864 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 06:42:12
合計ジャッジ時間 2,808 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 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,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  ios::sync_with_stdio(false);

  vector<int> N(256); {
    for (int i = 'A'; i <= 'C'; ++i) {
      cin >> N[i];
    }
  }

  char S0, S1;
  int64_t T0, T1; {
    cin >> S0 >> T0;
    cin >> S1 >> T1;
  }

  int64_t res = (int64_t) 1 << 60; {
    if (S0 == S1) res = min(res, abs(T1 - T0));
    res = min(res, T0 + T1 - 1);
    res = min(res, (N[S0] + 1 - T0) + (N[S1] + 1 - T1) - 1);
    int c = min({ N['A'], N['B'], N['C'] }) - 1;
    res = min(res, T0 + (N[S1] + 1 - T1) + c);
    res = min(res, (N[S0] + 1 - T0) + T1 + c);
  }

  cout << res << endl;
}
0