結果

問題 No.545 ママの大事な二人の子供
ユーザー agisagis
提出日時 2017-07-14 23:55:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 840 bytes
コンパイル時間 1,833 ms
コンパイル使用メモリ 171,004 KB
実行使用メモリ 817,760 KB
最終ジャッジ日時 2024-04-16 20:47:52
合計ジャッジ時間 5,643 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 32 ms
20,712 KB
testcase_19 AC 119 ms
72,272 KB
testcase_20 AC 462 ms
278,796 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 MLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const ll INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll>A(n), B(n);
	vector<ll>dist(n);
	map<ll, int>mp;
	rep(i, n) {
		cin >> A[i] >> B[i];
	}
	queue<ll>que;
	que.push(0);
	reps(i, 1, n) {
		ll count = pow(2, i)/2;
		while (count) {
			ll x = que.front();
			que.pop();
			que.push(x + A[i - 1]);
			que.push(x - B[i - 1]);
			count--;
		}
	}
	ll ans = INF;
	ll count = pow(2, n)/2;
	while (count) {
		ll x = que.front();
		que.pop();
		ans = min(min(abs(x + A[n - 1]), abs(x - B[n - 1])),ans);
		count--;
	}
	cout << ans << endl;
	return 0;
}
0