Tutorial For: 493-C Vasya and Basketball

Revision en1, by cn.Hwongfish, 2020-08-01 12:03:51

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) THE PROBLEM 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).

My English is awful right?

code: (if you have some question or hacking, please ask me below) ~~~~~

include

include

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); } ~~~~~

Tags #tutorial, novice coder, #code-download, nothing more

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English cn.Hwongfish 2020-08-01 12:19:07 293 Initial revision (published)
en1 English cn.Hwongfish 2020-08-01 12:03:51 1422 Initial revision (saved to drafts)