[BOJ] 1946 신입 사원

Time Lapse :NONE

1946.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstdio>

using namespace std;

#define MAXSIZE 100000
int N;
int n;
int item1, item2;
vector<int> ans_arr;
vector<pair<int,int>> arr;
int ans;
int comp;

int main(void)
{
cin>>N;
for(int i=0;i<N;i++)
{
ans = 1;
cin>>n;
for(int j=0;j<n;j++)
{
cin>>item1>>item2;
arr.push_back(make_pair(item1, item2));
}

sort(arr.begin(),arr.end());
comp=arr[0].second;
for(int j=1;j<arr.size();j++)
{
if(arr[j].second<comp)
{
comp=arr[j].second;
ans++;
}
}
arr.erase(arr.begin(),arr.end());
ans_arr.push_back(ans);
}
for(int i=0;i<ans_arr.size();i++)
cout<<ans_arr[i]<<endl;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/BOJ/1946/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.