Advertisement
Guest User

classifica

a guest
Aug 3rd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <fstream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. short rl(short campionato[], short N, short M)
  7. {
  8.     short i=0;
  9.     short pos=-1;
  10.     while(i<N && pos==-1)
  11.     {
  12.         if(campionato[i] == M)
  13.             pos = i;
  14.         i++;
  15.     }
  16.     return pos;
  17. }
  18.  
  19. int main()
  20. {
  21.     short N;
  22.     short s1, s2, g1, g2;
  23.     ifstream input;
  24.     ofstream output;
  25.     input.open("input.txt");
  26.     output.open("output.txt");
  27.     input >> N;
  28.     short campionato[N] = {0};
  29.     for(int i=0; i<N*(N-1)/2; i++)
  30.     {
  31.         input >> s1 >> s2 >> g1 >> g2;
  32.         if(g1>g2) campionato[s1] += 3;
  33.         else if(g1==g2) { campionato[s1]+=1; campionato[s2]+=1; }
  34.         else campionato[s2] += 3;
  35.     }
  36.     short M = *max_element(campionato, campionato+N);
  37.     output << rl(campionato,N,M) << ' ' << M;
  38.     input.close();
  39.     output.close();
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement