---
# System prepended metadata

title: 20191214TOI新手同好會3.站牌廣告

---

# 20191214TOI新手同好會3.站牌廣告

---

題目連結：https://zerojudge.tw/ShowProblem?problemid=e796

---

```clike=
#include<iostream>
using namespace std;

int main(){
	int b, p, start, stop, min, max, mini = 1005, maxi = 0;
	int bs[1005] = {0};
	cin >> b >> p;
	while(p--){
		cin >> start >> stop;
		if(start > stop){
			int temp = start;
			start = stop;
			stop = temp;
		}
		for(int i = start; i <= stop; i++)
			bs[i]++;
	}
	for(int i = 1; i <= b; i++){
		if(bs[i] < mini){
			mini = bs[i];
			min = i;
		}
		if(bs[i] >= maxi){
			maxi = bs[i];
			max = i;
		}
	}
	cout << min << " " << max;
	return 0;
} 
```

---

解題想法：
計算各站的經過人數