Tutorial For: 493-C Vasya and Basketball
- Hello! This is my frist blog of course, my English is not very good, forgive me.
- (JUST novice coder)
- 493C - Vasya and Basketball\
- My algorithm has these points need to be careful:
- 1: I put the data of to teams together (int c[]).
- 2: I assume the line is on 0, and team 1 has (3*n) points, team 2 has (3*m).
- 3: SORT THE DATA
- 4: I enumeration every distance which we can see it in data of BOTH team.
- 5: Don't forget to enumeration the distance after the data (the: n+1).
HaHaHa,let me laugh at myself for a minute!
- code:
- (if you have some question or hacking, please ask me below)
#include<iostream>
#include<algorithm>
using namespace std;
pair<int, int> a[500000] = { make_pair(0, 0) };
int n = 0, m = 0;
int x = 0, y = 0, mx = 0, my = 0;
int main() {
cin >> n;
for (int i = 0; i < n; ++i)
cin >> a[i].first, a[i].second = 0;
cin >> m;
for (int i = n; i < m + n; ++i)
cin >> a[i].first, a[i].second = 1;
sort(a, a + n + m);
x = n * 3; y = m * 3;
mx = x; my = y;
for (int i = 0; i < n + m; ++i) {
if (a[i].second == 0)x--;
else y--;
if (x — y > mx — my)
mx = x, my = y;
}
printf("%d:%d\n", mx, my);
}