結果

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