Notice
Recent Posts
Recent Comments
Link
할껀하고놀자
[백준] 1946번 신입사원 본문
728x90
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<pair<int, int>> a;
int main() {
int t;
cin >> t;
while (t--) {
a.clear();
int n, min = 100001, result = 0;
cin >> n;
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
a.push_back(make_pair(x, y));
}
sort(a.begin(), a.end());
for (int i = 0; i < n; i++) {
if (min > a[i].second) {
min = a[i].second;
result++;
}
}
cout << result << endl;
}
return 0;
}
포인트 : 아이디어가 좀 재미있었다. min 값이 계속 최소화되면서 그보다 더 작은 값이 나온다면 하나씩 더해주는 방식을 채택하였다.
'[IT] > 백준' 카테고리의 다른 글
[백준] 2346번 풍선 터뜨리기 (0) | 2019.06.08 |
---|---|
[백준] 1931번 회의실 배정 (0) | 2019.06.02 |
[백준] 1541번 잃어버린 괄호 (0) | 2019.06.01 |
[백준] 2217번 로프 (0) | 2019.06.01 |
[백준] 11399번 ATM (0) | 2019.06.01 |
Comments