12565 | 2024-12-23 13:14:03 | 4rt3xp0 | 2016. január | cpp17 | Accepted | 140ms | 4152 KiB |
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k; cin >> n >> k;
vector<int> v(n,0);
while(k--){
int x,y; cin >> x >> y;
x--; v[x]++;
if(y<n) v[y]--;
}
for(int i=1;i<n;i++) v[i]+=v[i-1];
sort(v.begin(),v.end());
cout << v[n/2];
}
1
Expected output:1
Checker output:ok 1 number(s): "1"
3707
Expected output:3707
Checker output:ok 1 number(s): "3707"
3413
Expected output:3413
Checker output:ok 1 number(s): "3413"
3071
Expected output:3071
Checker output:ok 1 number(s): "3071"
596
Expected output:596
Checker output:ok 1 number(s): "596"
2408
Expected output:2408
Checker output:ok 1 number(s): "2408"
699
Expected output:699
Checker output:ok 1 number(s): "699"
362
Expected output:362
Checker output:ok 1 number(s): "362"
4983
Expected output:4983
Checker output:ok 1 number(s): "4983"
6754
Expected output:6754
Checker output:ok 1 number(s): "6754"
6531
Expected output:6531
Checker output:ok 1 number(s): "6531"
2473
Expected output:2473
Checker output:ok 1 number(s): "2473"
2375
Expected output:2375
Checker output:ok 1 number(s): "2375"
2051
Expected output:2051
Checker output:ok 1 number(s): "2051"
1691
Expected output:1691
Checker output:ok 1 number(s): "1691"
1400
Expected output:1400
Checker output:ok 1 number(s): "1400"
3428
Expected output:3428
Checker output:ok 1 number(s): "3428"
895
Expected output:895
Checker output:ok 1 number(s): "895"
821
Expected output:821
Checker output:ok 1 number(s): "821"
482
Expected output:482
Checker output:ok 1 number(s): "482"
167
Expected output:167
Checker output:ok 1 number(s): "167"
4059
Expected output:4059
Checker output:ok 1 number(s): "4059"
1859
Expected output:1859
Checker output:ok 1 number(s): "1859"
1523
Expected output:1523
Checker output:ok 1 number(s): "1523"
6036
Expected output:6036
Checker output:ok 1 number(s): "6036"
836
Expected output:836
Checker output:ok 1 number(s): "836"