結果
| 問題 |
No.126 2基のエレベータ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-01-17 07:46:37 |
| 言語 | Go (1.23.4) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 436 bytes |
| コンパイル時間 | 11,401 ms |
| コンパイル使用メモリ | 232,728 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-10 02:50:07 |
| 合計ジャッジ時間 | 12,454 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 WA * 5 |
ソースコード
package main
import (
"fmt"
"math"
)
func AbsInt(x int) int {
return int(math.Abs(float64(x)))
}
func resolve(A, B, S int) int {
ret := S
if AbsInt(A-S) <= AbsInt(B-S) {
// Move A
return ret + AbsInt(A-S)
}
// Move B + A (goto 1st floor)
if A == 0 {
ret += 1
} else {
ret += A - 1
}
return ret + AbsInt(B-S)
}
func main() {
var A, B, S int
fmt.Scanf("%d %d %d\n", &A, &B, &S)
fmt.Println(resolve(A, B, S))
}