Alex_tz307

School - Level 1

Oct 30th, 2020 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. ifstream fin("text.in");
  6. ofstream fout("text.out");
  7.  
  8. int main() {
  9.     fin.sync_with_stdio(false);
  10.     fout.sync_with_stdio(false);
  11.     fin.tie(nullptr);
  12.     fout.tie(nullptr);
  13.     int N, P;
  14.     fin >> N >> P;
  15.     int mx = INT_MIN, ID = INT_MAX;
  16.     for(int itr = 0; itr < N; ++itr) {
  17.         int id1, score1, id2, score2;
  18.         fin >> id1 >> score1 >> id2 >> score2;
  19.         if(score1 > mx) {
  20.             mx = score1;
  21.             ID = id1;
  22.         }
  23.         else
  24.             if(score1 == mx && ID > id1)
  25.                 ID = id1;
  26.         if(score2 > mx) {
  27.             mx = score2;
  28.             ID = id2;
  29.         }
  30.         else
  31.             if(score2 == mx && ID > id2)
  32.                 ID = id2;
  33.     }
  34.     fout << ID << ' ' << mx;
  35. }
  36.  
Add Comment
Please, Sign In to add comment