Alex_tz307

School-CCC Ranking System - Level 5

Oct 27th, 2020 (edited)
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define int long long
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("text.in");
  7. ofstream fout("text.out");
  8.  
  9. const int NMAX = 1e5;
  10.  
  11. inline int seconds(string s) {
  12.     return ((s[0] - '0') * 10 + (s[1] - '0')) * 3600 + ((s[3] - '0') * 10 + (s[4] - '0')) * 60 + ((s[6] - '0') * 10 + (s[7] - '0'));
  13. }
  14.  
  15. inline bool fcmp(const pair < int , int >& A, const pair < int , int >& B) {
  16.     return A.first > B.first || (A.first == B.first && A.second < B.second);
  17. }
  18.  
  19. int32_t main() {
  20.     string start, ans;
  21.     int X, cnt;
  22.     fin >> start >> X >> cnt;
  23.     vector < tuple < int , int , int > > a;
  24.     vector < bool > ok(NMAX + 1);
  25.     for(int tt = 0; tt < cnt; ++tt) {
  26.         int id, tid;
  27.         string moment, type;
  28.         fin >> id >> moment >> type >> tid;
  29.         if(type == "correct")
  30.             a.push_back(make_tuple(seconds(moment), id, tid));
  31.         ok[id] = true;
  32.     }
  33.     sort(a.begin(), a.end());
  34.     vector < int > points(NMAX + 1, X), values(NMAX + 1);
  35.     for(auto x : a) {
  36.         values[get<1>(x)] += points[get<2>(x)];
  37.         if(points[get<2>(x)] > 0)
  38.             --points[get<2>(x)];
  39.     }
  40.     vector < pair < int , int > > sol;
  41.     for(int i = 0; i <= NMAX; ++i)
  42.         if(ok[i])
  43.             sol.emplace_back(values[i], i);
  44.     sort(sol.begin(), sol.end(), fcmp);
  45.     for(auto x : sol)
  46.         fout << x.first << ' ' << x.second << ' ';
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment