Advertisement
Guest User

Untitled

a guest
Dec 4th, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<cstdlib>
  5. #include<climits>
  6. #include<cmath>
  7. #include<string>
  8. #include<sstream>
  9. #include<vector>
  10. #include<list>
  11. #include<deque>
  12. #include<stack>
  13. #include<queue>
  14. #include<set>
  15. #include<map>
  16. #include<algorithm>
  17. #include<iterator>
  18. #include<numeric>
  19. #include<fstream>
  20.  
  21. #define FORF(i,a,b) for(int i=a; i<=b; ++i)
  22. #define FORB(i,a,b) for(int i=a; i>=b; --i)
  23. #define ALL(v) v.begin(),v.end()
  24. #define min3(a,b,c) min(min(a,b),c)
  25. #define SIZE 400010
  26. #define MAXN 3000000
  27.  
  28. using namespace std;
  29.  
  30.  
  31. typedef long long LL;
  32.  
  33.  
  34. struct basket
  35. {
  36.     int team;
  37.     LL dist;
  38.  
  39.     friend bool operator<(basket b1,basket b2)
  40.     {
  41.         return b1.dist<b2.dist;
  42.     }
  43. };
  44.  
  45. int N,M;
  46. int cnt1,cnt2;
  47. LL scA,scB,cuA,cuB;
  48.  
  49.  
  50. int main()
  51. {
  52.     basket bsk[SIZE];
  53.  
  54.     scanf("%d",&N);
  55.     FORF(i,0,N-1)
  56.     {
  57.         scanf("%I64d",&bsk[i].dist);
  58.         bsk[i].team=1;
  59.     }
  60.  
  61.     scanf("%d",&M);
  62.     FORF(i,0,M-1)
  63.     {
  64.         scanf("%I64d",&bsk[i+N].dist);
  65.         bsk[i+N].team=2;
  66.     }
  67.  
  68.  
  69.     sort(bsk,bsk+N+M);
  70.  
  71.  
  72.     scA=3*N;
  73.     scB=3*M;
  74.     FORF(i,0,N+M-1)
  75.     {
  76.         if(bsk[i].team==1)
  77.             ++cnt1;
  78.         else
  79.             ++cnt2;
  80.  
  81.  
  82.         cuA=2*cnt1 + 3*(N-cnt1);
  83.         cuB=2*cnt2 + 3*(M-cnt2);
  84.  
  85.  
  86.         if(cuA-cuB>scA-scB || (cuA-cuB==scA-scB && cuA>scA))
  87.         {
  88.             scA=cuA;
  89.             scB=cuB;
  90.         }
  91.     }
  92.  
  93.  
  94.     printf("%I64d:%I64d\n",scA,scB);
  95.  
  96.  
  97.     return 0;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement