#include <bits/stdc++.h>
#define fastio cin.tie(0)->sync_with_stdio(0)
using namespace std;
int T, N, ret;
vector <pair<int, int>> score;
int main(){
fastio;
cin>>T;
while(T--){
cin>>N;
score.clear(); //여러 번 반복하므로 초기화 필요
for(int i=0; i<N; i++){
int s, w;
cin >> s>> w;
score.push_back({s,w});
}
sort(score.begin(), score.end());
int tmp=0; //기준
ret=1;
for(int i=0; i<N; i++){
if(score[tmp].second > score[i].second){
ret++;
tmp=i; //현재 선택한 인덱스
}
}
cout<<ret<<'\n';
}
return 0;
}
문제를 이해하는 데에 오래 걸렸다. 숫자를 점수가 아닌 순위로 봐야한다.
서류 심사 순위를 기준으로 면접 순위를 비교하는 형식으로 풀었다.
test 케이스 개수가 제시되므로 score.clear()를 통해 초기화하는 과정이 필요하다.
<참고>
https://velog.io/@rhkswls98/%EB%B0%B1%EC%A4%80-1946-C-%EC%8B%A0%EC%9E%85-%EC%82%AC%EC%9B%90
'기타 > 백준일지' 카테고리의 다른 글
[백준] 2151번 거울 설치 (0) | 2025.02.17 |
---|---|
[백준] 19598번 최소 회의실 개수 (0) | 2025.02.14 |
[백준] 17503번 맥주축제 (0) | 2025.02.12 |
[백준] 2615번 오목 (0) | 2025.02.06 |
[백준] 2529번 부등호 (0) | 2025.02.05 |