-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path253B.cpp
More file actions
31 lines (28 loc) · 680 Bytes
/
Copy path253B.cpp
File metadata and controls
31 lines (28 loc) · 680 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
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 5000;
const int INF = 1e9;
int sum(vector<int>&a, int l, int r){
if(l > r) return 0;
if(!l) return a[r];
return a[r] - a[l-1];
}
main()
{
ifstream fin("input.txt");
ofstream fout("output.txt");
int n,minx=INF;
fin >> n;
vector<int> a(N+1,0);
vector<int> pref(N+1,0);
for(int i=0; i<n; i++) {
int x;
fin >> x;
a[x]++;
}
pref[0] = a[0];
for(int i = 1; i <= N; i++) pref[i]=pref[i-1]+a[i];
for(int i = 1; i <= N; i++) minx = min(minx,sum(pref,0,i-1)+sum(pref,2*i+1,N));
fout << minx;
}