-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6485.cpp
More file actions
48 lines (46 loc) · 937 Bytes
/
6485.cpp
File metadata and controls
48 lines (46 loc) · 937 Bytes
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
// 6485.삼성시의 버스 노선
// 2019.06.29
#include<iostream>
#include<vector>
using namespace std;
int busStop[5001]; // busStop[i] : i번째 정류장을 지나가는 버스의 수
int main()
{
int test_case;
int T;
cin >> T;
for (test_case = 1; test_case <= T; ++test_case)
{
fill(busStop, busStop + 5001, 0);
int n;
cin >> n;
// 버스정류장마다 몇대의 버스가 지나가는지 계산
for (int i = 0; i < n; i++)
{
int a, b;
cin >> a >> b;
for (int j = a; j <= b; j++)
{
busStop[j]++;
}
}
int p;
cin >> p;
vector<int> v;
// num번째 지나는 버스의 수 저장
for (int i = 0; i < p; i++)
{
int num;
cin >> num;
v.push_back(busStop[num]);
}
// 결과 출력
cout << "#" << test_case << " ";
for (int i = 0; i < v.size(); i++)
{
cout << v[i] << " ";
}
cout << endl;
}
return 0;//정상종료시 반드시 0을 리턴해야합니다.
}