結果
| 問題 |
No.126 2基のエレベータ
|
| コンテスト | |
| ユーザー |
ぴろず
|
| 提出日時 | 2015-01-13 23:52:18 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 595 bytes |
| コンパイル時間 | 2,506 ms |
| コンパイル使用メモリ | 83,480 KB |
| 実行使用メモリ | 56,056 KB |
| 最終ジャッジ日時 | 2024-06-22 05:39:49 |
| 合計ジャッジ時間 | 7,640 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 8 |
ソースコード
package no126;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
System.out.println(solve(a,b,c));
}
public static int solve(int a,int b,int s) {
int la = Math.abs(a-s);
int lb = Math.abs(b-s);
int ans = 0;
if (a == 0) {
if (la <= lb) {
return la + s;
}else{
return lb + s + 1;
}
}else{
if (la <= lb) {
return la + s;
}else{
return Math.min(lb + Math.abs(a-b) + a,lb + (s-1) + a);
}
}
}
}
ぴろず