結果

問題 No.126 2基のエレベータ
ユーザー hotpepsihotpepsi
提出日時 2015-01-14 00:17:05
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 488 bytes
コンパイル時間 674 ms
コンパイル使用メモリ 61,060 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-22 11:08:47
合計ジャッジ時間 1,631 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <list>

using namespace std;

int main(int argc, char *argv[])
{
	int A, B, S;
	string s;
	getline(cin, s);
	stringstream ss(s);
	ss >> A >> B >> S;
	int ans = 0;
	int a = abs(A - S), b = abs(B - S);
	if (a <= b || S <= 1) {
		ans = a + S;
	} else {
		ans = b;
		if (A < B) {
			ans += A;
		} else if (A < B * 2) {
			ans += A - B;
			ans += A;
		} else {
			ans += A + B - 1;
		}
	}
	cout << ans << endl;
	return 0;
}
0