Submission #1299278


Source Code Expand

Copy
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main(){
	using ll = long long;
	ll n;
	cin >> n;
	priority_queue<ll, vector<ll>, greater<ll>> a;
	vector<ll> b(n);
	priority_queue<ll> c;
	for(int i = 0; i < n; i++){
		ll x;
		cin >> x;
		a.push(x);
	}
	for(int i = 0; i < n; i++) cin >> b[i];
	for(int i = 0; i < n; i++){
		ll x;
		cin >> x;
		c.push(x);
	}
	ll f = 0, e = n - 1;
	while(f <= e){
		ll puni = b[f] - a.top(), muni = b[e] - c.top();
		if(abs(puni) < abs(muni)){
			c.pop();
			c.push(b[e--]);
		}else{
			a.pop();
			a.push(b[f++]);
		}
	}
	ll sa = 0, sc = 0;
	while(!a.empty()){
		sa += a.top();
		cerr << 'a' << a.top() << endl;
		a.pop();
	}
	while(!c.empty()){
		sc += c.top();
		cerr << 'c' << c.top() << endl;
		c.pop();
	}
	cout << sa - sc << endl;
}

Submission Info

Submission Time
Task D - 3N Numbers
User jbyxm
Language C++14 (GCC 5.4.1)
Score 0
Code Size 849 Byte
Status
Exec Time 387 ms
Memory 3444 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt
Subtask 0 / 300 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt
All 0 / 200 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 2_00.txt, 2_01.txt, 2_02.txt, 2_03.txt, 2_04.txt, 2_05.txt, 2_06.txt, 2_07.txt, 2_08.txt, 2_09.txt, 2_10.txt, 2_11.txt, 2_12.txt, 2_13.txt, 2_14.txt, 2_15.txt
Case Name Status Exec Time Memory
0_00.txt 1 ms 256 KB
0_01.txt 1 ms 256 KB
0_02.txt 1 ms 256 KB
1_00.txt 1 ms 256 KB
1_01.txt 1 ms 256 KB
1_02.txt 1 ms 256 KB
1_03.txt 1 ms 256 KB
1_04.txt 1 ms 256 KB
1_05.txt 1 ms 256 KB
1_06.txt 1 ms 256 KB
1_07.txt 1 ms 256 KB
1_08.txt 4 ms 256 KB
1_09.txt 5 ms 256 KB
1_10.txt 5 ms 256 KB
1_11.txt 5 ms 256 KB
1_12.txt 5 ms 256 KB
1_13.txt 5 ms 256 KB
1_14.txt 5 ms 256 KB
1_15.txt 5 ms 256 KB
1_16.txt 4 ms 256 KB
1_17.txt 4 ms 256 KB
1_18.txt 4 ms 256 KB
1_19.txt 4 ms 256 KB
1_20.txt 5 ms 256 KB
1_21.txt 5 ms 256 KB
1_22.txt 5 ms 256 KB
1_23.txt 5 ms 256 KB
2_00.txt 290 ms 3316 KB
2_01.txt 373 ms 3444 KB
2_02.txt 343 ms 3316 KB
2_03.txt 345 ms 3316 KB
2_04.txt 345 ms 3316 KB
2_05.txt 356 ms 3316 KB
2_06.txt 344 ms 3316 KB
2_07.txt 344 ms 3316 KB
2_08.txt 292 ms 3316 KB
2_09.txt 289 ms 3316 KB
2_10.txt 292 ms 3316 KB
2_11.txt 286 ms 3316 KB
2_12.txt 384 ms 3316 KB
2_13.txt 387 ms 3316 KB
2_14.txt 387 ms 3316 KB
2_15.txt 386 ms 3316 KB