Advertisement
Guest User

C - Leading the Scoreboard

a guest
Aug 22nd, 2017
421
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. using ll = long long;
  5.  
  6. map<string, int> acs;
  7. map<string, int> tim;
  8. map<string, map<char, int>> was;
  9.  
  10. int main() {
  11.     ios::sync_with_stdio(false);
  12.  
  13.     int n, m, p;
  14.     cin >> n >> m >> p;
  15.  
  16.     vector<string> teams;
  17.     for (int i = 0; i < n; i++) {
  18.         string w;
  19.         cin >> w;
  20.         teams.push_back(w);
  21.     }
  22.  
  23.     int b1 = 0, b2 = 0;
  24.     int ans = 0;
  25.     int last_t = 0;
  26.     while (m--) {
  27.         string w;
  28.         char p;
  29.         int t;
  30.         string verd;
  31.         cin >> w >> p >> t >> verd;
  32.  
  33.         int ok = 0;
  34.         ok += acs[teams[0]] == b1;
  35.         ok += tim[teams[0]] == b2;
  36.  
  37.         if (ok == 2) {
  38.             ans += t - last_t;
  39.         }
  40.  
  41.         if (verd == "NO") {
  42.             was[w][p]++;
  43.         } else if (verd == "OK") {
  44.             acs[w]++;
  45.             tim[w] += t + 20 * was[w][p];
  46.  
  47.             if (acs[w] > b1) {
  48.                 b1 = acs[w];
  49.                 b2 = tim[w];
  50.             } else if (acs[w] == b1) {
  51.                 b2 = min(b2, tim[w]);
  52.             }
  53.         }
  54.  
  55.         last_t = t;
  56.     }
  57.  
  58.     int ok = 0;
  59.     ok += acs[teams[0]] == b1;
  60.     ok += tim[teams[0]] == b2;
  61.  
  62.     if (ok == 2) {
  63.         ans += 300 - last_t;
  64.     }
  65.  
  66.     cout << ans << endl;
  67.  
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement