Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef unsigned long long Int;
  5.  
  6. #ifdef LOCAL
  7. #define getchar_unlocked() getchar()
  8. #endif
  9.  
  10. int n, sa, sb, sc, x;
  11. vector<pair<Int, char> > ans;
  12.  
  13. inline void rd(int &x) {
  14.     register int c = getchar_unlocked();
  15.     x = 0;
  16.     int neg = 0;
  17.  
  18.     if (c == EOF) {
  19.         x = EOF;
  20.         return;
  21.     }
  22.  
  23.     for (; ((c<48 || c>57) && c != '-'); c = getchar_unlocked());
  24.  
  25.     if (c == '-') {
  26.         neg = 1;
  27.         c = getchar_unlocked();
  28.     }
  29.  
  30.     for (; c>47 && c<58; c = getchar_unlocked()) {
  31.         x = (x << 1) + (x << 3) + c - 48;
  32.     }
  33.  
  34.     if (neg) {
  35.         x = -x;
  36.     }
  37. }
  38.  
  39. int main(void) {
  40.  
  41. #ifdef LOCAL
  42.     freopen("in.txt", "r", stdin);
  43. #endif
  44.    
  45.     cin >> n;
  46.     for (int k = 0; k < n; k++) {
  47.         rd(sa); rd(sb); rd(sc);
  48.  
  49.         Int aux = 0;
  50.         for (int i = 0; i < sa; i++) {
  51.             rd(x);
  52.             aux += ((Int)x * x * x);
  53.         }
  54.         ans.push_back(make_pair(aux, 'A'));
  55.         aux = 0;
  56.         for (int i = 0; i < sb; i++) {
  57.             rd(x);
  58.             aux += ((Int)x * x * x);
  59.         }
  60.         ans.push_back(make_pair(aux, 'B'));
  61.         aux = 0;
  62.         for (int i = 0; i < sc; i++) {
  63.             rd(x);
  64.             aux += ((Int)x * x * x);
  65.         }
  66.         ans.push_back(make_pair(aux, 'C'));
  67.  
  68.         sort(ans.begin(), ans.end());
  69.        
  70.         printf("Case #%d: ", k + 1);
  71.         if (ans[2].first == ans[1].first)
  72.             puts("TIE");
  73.         else
  74.             printf("%c\n", ans[2].second);
  75.         ans.clear();
  76.     }
  77.    
  78.     return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement