結果

問題 No.126 2基のエレベータ
ユーザー togaerror
提出日時 2015-03-25 22:56:32
言語 Perl
(5.40.0)
結果
WA  
実行時間 -
コード長 375 bytes
コンパイル時間 28 ms
コンパイル使用メモリ 5,760 KB
実行使用メモリ 5,760 KB
最終ジャッジ日時 2024-06-29 00:57:56
合計ジャッジ時間 1,034 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/perl

use warnings;
use strict;

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

if($x < 0) {
	$x *= -1;
}

if($y < 0) {
	$y *= -1;
}

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

print "$count\n";

exit;
0