結果
問題 |
No.859 路線A、路線B、路線C
|
ユーザー |
![]() |
提出日時 | 2021-05-07 17:09:07 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,536 bytes |
コンパイル時間 | 1,565 ms |
コンパイル使用メモリ | 105,088 KB |
実行使用メモリ | 18,688 KB |
最終ジャッジ日時 | 2024-09-15 05:30:10 |
合計ジャッジ時間 | 2,615 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 2 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Linq; using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); line = Console.ReadLine().Trim().Split(' '); var s0 = line[0]; var t0 = int.Parse(line[1]); line = Console.ReadLine().Trim().Split(' '); var s1 = line[0]; var t1 = int.Parse(line[1]); if (s0 == s1) { if (s0 == "A") Same(a, t0, t1, 0, 1, 2); else if (s0 == "B") Same(a, t0, t1, 1, 0, 2); else Same(a, t0, t1, 2, 0, 1); } else { if ((s0 == "A" && s1 == "B") | (s0 == "B" && s1 == "A")) Diff(a, t0, t1, 0, 1, 2); else if ((s0 == "B" && s1 == "C") | (s0 == "C" && s1 == "B")) Diff(a, t0, t1, 1, 2, 0); else Diff(a, t0, t1, 0, 2, 1); } } static void Diff(int[] a, int t0, int t1, int p, int q, int r) { var root = new long[4]; root[0] = t0 + t1 - 1L; root[1] = (a[p] - t0) + (a[q] - t1) + 1L; root[2] = t0 + a[r] + a[q] - t1; root[3] = a[p] - t0 + a[r] + t1; Console.WriteLine(root.Min()); } static void Same(int[] a, int t0, int t1, int p, int q, int r) { if (t0 > t1) { Same(a, t1, t0, p, q, r); return; } var root = new long[3]; root[0] = t1 - t0; root[1] = t0 + a[q] + a[p] - t1; root[2] = t0 + a[r] + a[p] - t1; Console.WriteLine(root.Min()); } }