fork download
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main(){
  7.  
  8. int n;
  9. cin>>n; // 득점의 횟수
  10.  
  11. string time; //입력받을 시간
  12. int m,s; // 입력받은 시간을 int로 쪼갤때 사용
  13. int team, team1=0,team2=0; //입력받는 team 번호, team1 2가 이기고 있던 시간
  14. int team1_s=0,team2_s=0; //team1 2 의 점수
  15. int t = 48*60; //전체 시간
  16. bool a=true;
  17.  
  18. for(int i=0;i<n;i++){
  19. cin>>team>>time;
  20. m = stoi(time.substr(0,2));
  21. s = stoi(time.substr(3,2));
  22.  
  23. if(team==1) team1_s++;
  24. else if (team==2) team2_s++;
  25.  
  26. if(a==true){
  27. if(team1_s-team2_s==1){
  28. team1 = team1+(t-(m*60+s));
  29. a=false;
  30. }
  31. else if (team2_s-team1_s==1){
  32. team2 = team2+(t-(m*60+s));
  33. a=false;
  34. }
  35. }
  36. if(team1_s-team2_s==0){
  37. if(team1>0) team1-=(t-(m*60+s));
  38. if(team2>0) team2-=(t-(m*60+s));
  39. a=true;
  40. }
  41.  
  42. }
  43. printf("%02d:%02d\n", team1 / 60, team1 % 60);
  44. printf("%02d:%02d\n", team2 / 60, team2 % 60);
  45. }
Success #stdin #stdout 0.01s 5516KB
stdin
8
1 00:00
1 00:40
2 00:50
2 00:59 
2 01:50
1 01:59
1 02:00
2 02:59
stdout
-44:-3
-44:-52