結果
| 問題 |
No.126 2基のエレベータ
|
| コンテスト | |
| ユーザー |
koyumeishi
|
| 提出日時 | 2015-01-13 23:50:38 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 694 bytes |
| コンパイル時間 | 655 ms |
| コンパイル使用メモリ | 72,512 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-21 19:11:14 |
| 合計ジャッジ時間 | 1,669 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 2 |
ソースコード
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;
int func(int a, int b, int s){
int ret = 0;
if(s==1){
//aが来る -> 0階へ
ret = abs(s-a) + abs(s-0);
}else{
if(abs(s-a) <= abs(s-b)){
//aが来る -> 0階へ
ret = abs(s-a) + abs(s-0);
}else{
//bが来る -> aのいる階へ
ret = abs(s-b) + abs(s-a) + func(a,a,a);
//bが来る -> 1階へ
ret = min( ret, abs(s-b) + abs(s-1) + func(a,1,1) );
}
}
return ret;
}
int main(){
int a,b,s;
cin >> a >> b >> s;
int ans = func(a,b,s);
cout << ans << endl;
return 0;
}
koyumeishi