結果

問題 No.126 2基のエレベータ
ユーザー しらゆき
提出日時 2015-11-23 13:19:23
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 943 ms
コンパイル使用メモリ 103,040 KB
実行使用メモリ 18,304 KB
最終ジャッジ日時 2024-09-13 17:13:54
合計ジャッジ時間 2,533 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 += s;
        }
        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