C++代码
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1000010;
int n, k;
int dif[N], res[N];
int main(){
cin >> n >> k;
while(k--){
int a, b;
cin >> a >> b;
dif[a]++;
dif[b + 1]--;
}
for(int i = 1; i <= n; ++i){
dif[i] = dif[i - 1] + dif[i];
}
sort(dif + 1, dif + 1 + n);
>
cout << dif[(n + 1) / 2] << endl;
return 0;
}
题库搜堆的时候看到这题以为是堆,看了半天点开算法标签发现是none - -!