채점한 학생의 점수가 모두 같다는 말에는, 책상이 연속적으로 위치해있어야한다는 조건이 숨어있다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <vector> | |
using namespace std; | |
int main(void) | |
{ | |
vector<int> A; | |
vector<int> B; | |
int N; | |
scanf("%d",&N); | |
for (int i=0;i<N;i++){ | |
int inputA,inputB; | |
scanf("%d %d",&inputA,&inputB); | |
A.push_back(inputA); | |
B.push_back(inputB); | |
} | |
int min_grade =0; | |
int max_len = -10001; | |
for (int grade=1;grade<=5;grade++){ | |
int len = 0; | |
for (int i=0;i<N;i++){ | |
if (grade == A[i] || grade == B[i]) | |
len++; | |
else len=0; | |
if (len > max_len) | |
{ | |
max_len = len; | |
min_grade = grade; | |
} | |
} | |
} | |
printf("%d %d",max_len,min_grade); | |
} |
댓글
댓글 쓰기