회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
채점 현황
게시판
그룹
더 보기
재채점 기록
블로그
도움말
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
반례가 뭔지 알 수 있을까요?
2852번 - NBA 농구
code_broker
2년 전
0
코드 더러워서 미안합니다.. 질문게시판 반례를 모두 넣어봐도 틀려서 그런데 반례를 알 수 있을까요?..ㅠ
#include <iostream> #include <algorithm> #include <string> using namespace std; int n; int a; string b; int scoreA; int scoreB; string recoredA; string recoredB; int sumHourA; int sumMA; int sumHourB; int sumMB; int main(){ cin>>n; for(int i=0;i<n;i++){ cin>>a>>b; //cout<< "A :" <<scoreA<<" B: "<<scoreB<<endl; if(a==1){//1 득점 if(scoreA==scoreB){//기존에 동점이면 //cout<<"A가 득점하여 A가 이기기 시작했습니다."<<endl; recoredA=b;//A가 이기기 시작한 시점 기록 } if(scoreB-1==scoreA){//A가 1점차로 지고 있었다면 //cout<<"A가 득점하여 동점이 됐습니다"<<endl; int tmpHourb=stoi(b.substr(0,2)); int tmpMb=stoi(b.substr(3,2)); int tmpHourrb=stoi(recoredB.substr(0,2)); int tmpMrb=stoi(recoredB.substr(3,2)); sumHourB+=tmpHourb-tmpHourrb;// A득점 시간 - B득점가 이기기 시작한 기록된 시간 //cout<<"B가 유리한 시간"<<tmpHourb-tmpHourrb<<endl; //cout<<"B가 유리한 분"<<tmpMb-tmpMrb<<endl; if(tmpMb>=tmpMrb) sumMB=tmpMb-tmpMrb; else { sumHourB--; sumMB+=60-(tmpMrb-tmpMb);//여기 부분 조심 } } scoreA++; } else{//2 득 if(scoreA==scoreB){//기존에 동점이면 //cout<<"B가 득점하여 이기기 시작 했습니다"<<endl; recoredB=b;//B가 이기기 시작한 시점 기록 } if(scoreA-1==scoreB){//B가 1점차로 지고 있었다면 //cout<<"B가 득점하여 동점이 됐습니다"<<endl; int tmpHourb=stoi(b.substr(0,2)); int tmpMb=stoi(b.substr(3,2)); int tmpHourra=stoi(recoredA.substr(0,2)); int tmpMra=stoi(recoredA.substr(3,2)); sumHourA+=tmpHourb-tmpHourra;// A득점 시간 - B득점시간 //cout<<"A가 유리한 시간"<<tmpHourb-tmpHourra<<endl; //cout<<"A가 유리한 분"<<tmpMb-tmpMra<<endl; if(tmpMb>=tmpMra) sumMA=tmpMb-tmpMra; else { sumHourA--; sumMA+=60-(tmpMra-tmpMb);//여기 부분 조심 } } scoreB++; } } if(scoreA>scoreB){ //cout<<"A가 이기면서 끝났습니다"<<endl; int tmpHourra=stoi(recoredA.substr(0,2)); //시작점 2개 //cout<<tmpHourra<<endl; int tmpMra=stoi(recoredA.substr(3,2)); //시작점 2개 //cout<<tmpMra<<endl; //cout<<"마지막 A부분 실행"<<endl; sumHourA+=48-tmpHourra;// A득점 시간 - B득점시간 이 부분 문제 없나? sumMA+=60-tmpMra;//여기 부분 조심 if(tmpMra!=0) { //cout<<"시간조정"<<endl; sumHourA--;//!!! 시간조정 } //cout<<"A가 유리한 시간"<<48-tmpHourra<<endl; //cout<<"A가 유리한 분"<<60-tmpMra<<endl; } if(scoreA<scoreB){ //cout<<"B가 이기면서 끝났습니다"<<endl; int tmpHourra=stoi(recoredB.substr(0,2)); int tmpMra=stoi(recoredB.substr(3,2)); sumHourB+=48-tmpHourra;// A득점 시간 - B득점시간 이 부분 문제 없나? sumMB+=60-tmpMra;//여기 부분 조심 if(tmpMra!=0) { //cout<<"시간조정"<<endl; sumHourB--; } //cout<<"B가 유리한 시간"<<48-tmpHourra<<endl; //cout<<"B가 유리한 분"<<60-tmpMra<<endl; } //cout<<recoredA<<endl; //cout<<scoreA<<endl; //cout<<scoreB<<endl; if(sumHourA <10) cout<<"0"; cout<<sumHourA<<":"; if(sumMA<10) { cout<<"0"; cout<<sumMA<<endl; } else if(sumMA==60) cout<<"00\n"; else cout<<sumMA<<endl; if(sumHourB <10) cout<<"0"; cout<<sumHourB<<":"; if(sumMB<10) { cout<<"0"; cout<<sumMB<<endl; } else if(sumMB==60) cout<<"00\n"; else cout<<sumMB<<endl; }
댓글을 작성하려면
로그인
해야 합니다.
code_broker 2년 전
코드 더러워서 미안합니다.. 질문게시판 반례를 모두 넣어봐도 틀려서 그런데 반례를 알 수 있을까요?..ㅠ