結果

問題 No.149 碁石の移動
ユーザー startcpp
提出日時 2015-02-12 23:34:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 565 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 53,500 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 02:45:29
合計ジャッジ時間 1,212 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

int aw, ab;
int bw, bb;
int c, d;

int main() {
	int i;
	cin >> aw >> ab;
	cin >> bw >> bb;
	cin >> c >> d;
	
	int wcnt, bcnt;
	//Aのwhiteは極力残す
	bcnt = min(ab, c);
	wcnt = c - bcnt;
	bw += wcnt;
	bb += bcnt;
	aw -= wcnt;
	ab -= bcnt;
	//cout << aw << " " << ab << " " << bw << " " << bb << endl;
	//Bのwhiteは極力Aに移す
	wcnt = min(bw, d);
	bcnt = d - wcnt;
	aw += wcnt;
	ab += bcnt;
	bw -= wcnt;
	bb -= bcnt;
	//cout << aw << " " << ab << " " << bw << " " << bb << endl;
	cout << aw << endl;
	return 0;
}
0