Tutorial For: 493-C Vasya and Basketball

Revision en2, by cn.Hwongfish, 2020-08-01 12:19:07

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)
  1. #include<iostream>
  2. #include<algorithm>
  3. using namespace std;
  4. pair<int, int> a[500000] = { make_pair(0, 0) };
  5. int n = 0, m = 0;
  6. int x = 0, y = 0, mx = 0, my = 0;
  7. int main() {
  8. cin >> n;
  9. for (int i = 0; i < n; ++i)
  10. cin >> a[i].first, a[i].second = 0;
  11. cin >> m;
  12. for (int i = n; i < m + n; ++i)
  13. cin >> a[i].first, a[i].second = 1;
  14. sort(a, a + n + m);
  15. x = n * 3; y = m * 3;
  16. mx = x; my = y;
  17. for (int i = 0; i < n + m; ++i) {
  18. if (a[i].second == 0)x--;
  19. else y--;
  20. if (x &mdash; y > mx &mdash; my)
  21. mx = x, my = y;
  22. }
  23. printf("%d:%d\n", mx, my);
  24. }
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)