結果
| 問題 |
No.126 2基のエレベータ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-01-17 08:53:38 |
| 言語 | Go (1.23.4) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 617 bytes |
| コンパイル時間 | 10,772 ms |
| コンパイル使用メモリ | 233,616 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-21 19:35:16 |
| 合計ジャッジ時間 | 11,675 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 1 |
ソースコード
package main
import (
"fmt"
"math"
)
func MinInt(x, y int) int {
return int(math.Min(float64(x), float64(y)))
}
func AbsInt(x int) int {
return int(math.Abs(float64(x)))
}
func resolve(A, B, S int) int {
if AbsInt(A-S) <= AbsInt(B-S) {
// Move A
return AbsInt(A-S) + S
}
// Move B + A
if A == 0 {
// goto and upto 1st floor
return AbsInt(B-S) + S + 1
}
// goto 1st floor
tmp1 := AbsInt(B-S) + (S - 1) + A
// goto A floor
tmp2 := AbsInt(B-S) + AbsInt(A-S) + A
return MinInt(tmp1, tmp2)
}
func main() {
var A, B, S int
fmt.Scanf("%d %d %d\n", &A, &B, &S)
fmt.Println(resolve(A, B, S))
}