Alex_tz307

School - Level 3

Oct 30th, 2020 (edited)
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 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. bool fcmp(const pair < int , int >& a, const pair < int , int >& b) {
  9.     return a.second > b.second || (a.second == b.second && a.first < b.first);
  10. }
  11.  
  12. int main() {
  13.     fin.sync_with_stdio(false);
  14.     fout.sync_with_stdio(false);
  15.     fin.tie(nullptr);
  16.     fout.tie(nullptr);
  17.     int win, loss;
  18.     fin >> win >> loss;
  19.     int N, P;
  20.     fin >> N >> P;
  21.     vector < int > freq(P);
  22.     for(int itr = 0; itr < N; ++itr) {
  23.         int id1, score1, id2, score2;
  24.         fin >> id1 >> score1 >> id2 >> score2;
  25.         if(score1 > score2) {
  26.             freq[id1] += win;
  27.             freq[id2] -= loss;
  28.         }
  29.         else {
  30.             freq[id2] += win;
  31.             freq[id1] -= loss;
  32.         }
  33.     }
  34.     vector < pair < int , int > > sol;
  35.     for(int i = 0; i < P; ++i)
  36.         sol.emplace_back(i, freq[i]);
  37.     sort(sol.begin(), sol.end(), fcmp);
  38.     for(auto x : sol)
  39.         fout << x.first << ' ' << x.second << '\n';
  40. }
  41.  
Add Comment
Please, Sign In to add comment