結果

問題 No.126 2基のエレベータ
ユーザー しらゆきしらゆき
提出日時 2015-11-23 13:20:31
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 2,540 ms
コンパイル使用メモリ 103,404 KB
実行使用メモリ 22,844 KB
最終ジャッジ日時 2023-10-11 18:19:27
合計ジャッジ時間 5,180 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,744 KB
testcase_01 AC 57 ms
20,788 KB
testcase_02 AC 57 ms
20,780 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 58 ms
20,720 KB
testcase_06 WA -
testcase_07 AC 57 ms
18,716 KB
testcase_08 AC 57 ms
18,844 KB
testcase_09 AC 57 ms
20,772 KB
testcase_10 AC 56 ms
20,772 KB
testcase_11 AC 57 ms
20,744 KB
testcase_12 AC 57 ms
22,628 KB
testcase_13 WA -
testcase_14 AC 58 ms
22,844 KB
testcase_15 AC 58 ms
18,708 KB
testcase_16 AC 58 ms
22,820 KB
testcase_17 AC 58 ms
20,772 KB
testcase_18 AC 58 ms
22,676 KB
testcase_19 AC 58 ms
22,792 KB
testcase_20 AC 58 ms
20,744 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 59 ms
22,740 KB
testcase_27 AC 59 ms
20,736 KB
testcase_28 AC 58 ms
22,688 KB
testcase_29 AC 58 ms
22,796 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Program
{
    static void Main()
    {
        var tmp = Console.ReadLine().Split();
        int a = int.Parse(tmp[0]);
        int b = int.Parse(tmp[1]);
        int s = int.Parse(tmp[2]);

        int ans = 0;

        if (Math.Abs(a - s) <= Math.Abs(b - s))
        {
            if (a < s) ans += s - a;
            ans += a;
        }
        else
        {
            if (a < b)
            {
                if (a == 0) ans++;
                if (s < b) ans += b;
                else ans += 2 * s - b;
            }
            else
            {                
                if (s < b) ans += Math.Min(2 * a + b - 2 * s, a + b - 1);
                else ans += Math.Min(2 * a - b, s * 2 + a - b - 1);
                if (s == 1) ans = a;
            }
        }

        Console.WriteLine(ans);
    }
}
0