Advertisement
rdsedmundo

Untitled

May 22nd, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. #include <iostream>
  2. #include <utility>
  3. #include <algorithm>
  4. #include <string>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. bool compare(pair<int, string> x, pair<int, string> y) {
  10.    
  11.     if (x.first == y.first)
  12.         return x.second.compare(y.second);
  13.    
  14.     return x.first > y.first;  
  15. }
  16.  
  17. int main() {
  18.    
  19.     int teste = 0;
  20.     while (true) {
  21.        
  22.         int n;
  23.         cin >> n;
  24.        
  25.         if (!n)
  26.             break;
  27.        
  28.         vector<pair<int, string> > jog;
  29.         for (int i = 1; i <= n; i++) {
  30.             string nome;
  31.             cin >> nome;
  32.            
  33.             vector<int> ps;
  34.             for (int j = 1; j <= 12; j++) {
  35.                 int v;
  36.                 cin >> v;
  37.                
  38.                 ps.push_back(v);
  39.             }
  40.            
  41.             sort(ps.begin(), ps.end());
  42.            
  43.             int sum = 0;
  44.             for (int i = 1; i <= 10; i++)
  45.                 sum += ps.at(i);
  46.            
  47.             jog.push_back(make_pair(sum, nome));
  48.         }
  49.        
  50.         cout << "Teste " << ++teste << endl;
  51.        
  52.         sort(jog.begin(), jog.end(), compare);
  53.        
  54.         int posicao = 1;
  55.         for (int i = 0; i < jog.size(); i++) {
  56.             if (i == 0) {
  57.                 if (jog.at(i - 1).first == jog.at(i).first)
  58.                     posicao += 2;
  59.                 else
  60.                     posicao++;
  61.             }
  62.            
  63.             cout << posicao << " " << jog.at(i).first << " " << jog.at(i).second << endl;
  64.         }
  65.            
  66.         cout << endl;
  67.     }
  68.  
  69.     return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement