#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i, a, b) for(int i=a; i<b; i++)
#define ffi For(i, 0, N)
#define ffj For(j, 0, M)
#define ffa ffi ffj
#define s <<" "<<
#define w cout
#define e "\n"
#define pb push_back
#define mp make_pair
#define a first
#define b second
#define int ll
const int MAXN=1000000, INF=1000000000000000000;
///500,000,000
int D, N, inp[MAXN];
bool works(int m) {
int day = 1;
int lef = m;
ffi {
if (inp[i] > day) day=inp[i], lef = m;
if (inp[i] + D < day) return false;
lef--;
if (lef == 0) day++, lef=m;
}
return true;
}
main() {
//ifstream cin("test.in");
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> N >> D >> N;
ffi cin >> inp[i];
sort(inp, inp+N);
int a=1, b=N;
while (a != b) {
int mid = (a+b)/2;
if (works(mid)) b = mid;
else a = mid+1;
}
w<< a<<e;
}
Compilation message
jobs.cpp:32:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
1400 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
13 ms |
1828 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
13 ms |
2160 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
13 ms |
2404 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
12 ms |
2700 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
13 ms |
3124 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
13 ms |
3360 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
14 ms |
3784 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
15 ms |
4008 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
16 ms |
4260 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
19 ms |
4696 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
37 ms |
6280 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
52 ms |
8252 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
80 ms |
10928 KB |
Unexpected end of file - int32 expected |
15 |
Incorrect |
86 ms |
13604 KB |
Unexpected end of file - int32 expected |
16 |
Incorrect |
121 ms |
17332 KB |
Unexpected end of file - int32 expected |
17 |
Incorrect |
138 ms |
21492 KB |
Unexpected end of file - int32 expected |
18 |
Incorrect |
140 ms |
25416 KB |
Unexpected end of file - int32 expected |
19 |
Incorrect |
155 ms |
29660 KB |
Unexpected end of file - int32 expected |
20 |
Incorrect |
138 ms |
31308 KB |
Unexpected end of file - int32 expected |