/
D1A.cpp
57 lines (53 loc) · 851 Bytes
/
D1A.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,102400000")
int n;
int x[1000001];
bool check(int piles)
{
for(int i = 0; i < n; i++)
{
if(x[i] < i / piles)
return false;
}
return true;
}
int MAIN()
{
cin >> n;
for(int i = 0; i < n; i++)
cin >> x[i];
sort(x, x + n);
int L = 0, R = n, M;
while(R-L > 1)
{
M = (L + R) / 2;
if(check(M))
R = M;
else
L = M;
}
cout << R << endl;
return 0;
}
int main()
{
#ifdef LOCAL_TEST
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
ios :: sync_with_stdio(false);
cout << fixed << setprecision(16);
return MAIN();
}