Submission #4100885


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] = {(ll)i,a[i] + b[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].f];
		else ans -= b[x[i].f];
	}
	cout << ans;
	
	
	
	return 0;
}

Submission Info

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

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 a01, a02, a03
All 0 / 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 62 ms 5888 KB
b06 62 ms 5888 KB
b07 82 ms 5888 KB
b08 81 ms 5888 KB
b09 81 ms 5888 KB
b10 82 ms 5888 KB
b11 82 ms 5888 KB
b12 83 ms 5888 KB
b13 82 ms 5888 KB