結果
問題 | No.126 2基のエレベータ |
ユーザー |
![]() |
提出日時 | 2015-11-23 13:22:09 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 25 ms / 5,000 ms |
コード長 | 845 bytes |
コンパイル時間 | 771 ms |
コンパイル使用メモリ | 103,680 KB |
実行使用メモリ | 18,432 KB |
最終ジャッジ日時 | 2024-10-10 18:28:01 |
合計ジャッジ時間 | 2,383 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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 += 2 * s - a; else 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); } }