結果

問題 No.126 2基のエレベータ
ユーザー togaerrortogaerror
提出日時 2015-03-25 22:20:25
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 564 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 5,136 KB
最終ジャッジ日時 2023-09-11 10:16:01
合計ジャッジ時間 1,788 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 5 ms
5,048 KB
testcase_04 AC 5 ms
4,908 KB
testcase_05 AC 5 ms
5,080 KB
testcase_06 AC 5 ms
4,796 KB
testcase_07 WA -
testcase_08 AC 5 ms
4,904 KB
testcase_09 AC 5 ms
5,076 KB
testcase_10 WA -
testcase_11 AC 5 ms
4,872 KB
testcase_12 AC 5 ms
5,084 KB
testcase_13 AC 4 ms
4,980 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 4 ms
5,132 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 4 ms
4,816 KB
testcase_22 AC 5 ms
4,932 KB
testcase_23 AC 5 ms
4,984 KB
testcase_24 AC 5 ms
4,796 KB
testcase_25 AC 4 ms
4,868 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 4 ms
4,788 KB
testcase_29 AC 5 ms
5,008 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/perl

use warnings;
use strict;

my ($a, $b, $s) = split / /, <>;
my ($x, $y);
my $count = 0;

if($a < $s) {
	$x = $s - $a;
} else {
	$x = $a - $s;
}

if($b < $s) {
	$y = $s - $b;
} else {
	$y = $b - $s;
}

if($s == 1) {
	$count = $x + $a + 1;
} elsif ($x <= $y) {
	$count = $x + $s;
} else {
	if($a < $b) {
		if($b - 1 < $b - $a) {
			$count = $y + $b - $a + 1;
		} else {
			$count = $y + $b;
		}
	} else {
		if($b - 1 < $a - $b) {
			$count = $y + $a - $b + 1;
		} else {
			$count = $y + $b;
		}
	}
		
	$count = $y + $s;
}

print "$count\n";

exit;
0