mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-09 16:18:49 +00:00
2041. 干草堆
https://www.acwing.com/problem/content/submission/code_detail/9659094/
This commit is contained in:
parent
35bceee123
commit
31edb8e601
25
AcWing/2041/2041.cpp
Normal file
25
AcWing/2041/2041.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
const int N = 1000005;
|
||||
|
||||
int n, k, a, b, s[N], f[N];
|
||||
|
||||
int main() {
|
||||
cin >> n >> k;
|
||||
for (int i = 1; i <= k; i++) {
|
||||
cin >> a >> b;
|
||||
s[a] += 1;
|
||||
s[b + 1] -= 1;
|
||||
}
|
||||
for (int i = 1; i <= n; i++) {
|
||||
f[i] = f[i - 1] + s[i];
|
||||
}
|
||||
std::sort(f + 1, f + 1 + n);
|
||||
cout << f[n / 2 + 1] << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user