tonfain

TonfaiMooTimes

Dec 26th, 2023
1,134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct Stat{
  5.     int rnd, cow, pts;
  6. };
  7.  
  8. bool ascending_rnd(Stat a, Stat b){
  9.     return a.rnd < b.rnd;
  10. }
  11.  
  12. int main(){
  13.     ifstream fin("mootimes.in");
  14.    
  15.     int N;
  16.     fin >> N;
  17.    
  18.     vector<Stat> R(N);
  19.     for(int i = 0; i<N; i++){
  20.         int r, p;
  21.         string c;
  22.         fin >> r >> c >> p;
  23.        
  24.         R[i].rnd = r;
  25.         if(c == "Bessie"){
  26.             R[i].cow = 0;
  27.         }else if(c == "Mildred"){
  28.             R[i].cow = 1;
  29.         }else{
  30.             R[i].cow = 2;
  31.         }
  32.         R[i].pts = p;
  33.     }
  34.    
  35.     sort(R.begin(), R.end(), ascending_rnd);
  36.    
  37.     vector<bool> leaderboard = {1, 1, 1};
  38.     vector<int> P = {7, 7, 7};
  39.     int ans = 0;
  40.     for(int i = 0; i<N; i++){
  41.         int max = 0;
  42.         vector<int> ori(N);
  43.        
  44.         for(int j = 0; j<N; j++){
  45.             ori[j] = leaderboard[j];
  46.         }
  47.         P[R[i].cow] += R[i].pts;
  48.        
  49.         for(int j = 0; j<3; j++){
  50.             if(P[j] >= max){
  51.                 max = P[j];
  52.                 leaderboard[j] = true;
  53.             }
  54.         }
  55.         for(int j = 0; j<3; j++){
  56.             if(P[j] < max){
  57.                 leaderboard[j] = false;
  58.             }
  59.         }
  60.         bool diff = false;
  61.         //cout << "P: " << P[0] << " " << P[1] << " " << P[2] << ", leader board: " << leaderboard[0] << " " << leaderboard[1] << " " << leaderboard[2] << endl;
  62.         for(int j = 0; j<3; j++){
  63.             if(leaderboard[j] != ori[j]){
  64.                 diff = true;
  65.             }
  66.         }
  67.         if(diff){
  68.             ans++;
  69.         }
  70.     }
  71.     cout << ans << endl;
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment