Submission #4101707


Source Code Expand

Copy
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,a[200005],b[200005],ans;
pair<ll,ll>x[200005];
int main(){
	cin >> n;
	
	for(int i=1; i<=n; i++){
		cin >> a[i] >> b[i];
		x[i] = {a[i] + b[i],(ll)i};
	}
	sort(x+1,x+n+1);
	reverse(x+1,x+n+1);
	for(int i=1; i<=n; i++){
		if(i%2)ans += a[x[i].s];
		else ans -= b[x[i].s];
	}
	cout << ans;
	
	
	
	return 0;
}

Submission Info

Submission Time
Task C - Different Strokes
User abasadzishvili
Language C++14 (GCC 5.4.1)
Score 400
Code Size 457 Byte
Status
Exec Time 88 ms
Memory 5888 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 a01, a02, a03
All 400 / 400 a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13
Case Name Status Exec Time Memory
a01 2 ms 4352 KB
a02 2 ms 4352 KB
a03 2 ms 4352 KB
b04 2 ms 4352 KB
b05 63 ms 5888 KB
b06 63 ms 5888 KB
b07 88 ms 5888 KB
b08 88 ms 5888 KB
b09 87 ms 5888 KB
b10 88 ms 5888 KB
b11 88 ms 5888 KB
b12 88 ms 5888 KB
b13 87 ms 5888 KB