답안 #416390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
416390 2021-06-02T10:58:22 Z shubham20_03 Job Scheduling (CEOI12_jobs) C++17
0 / 100
150 ms 10820 KB
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
#define deb1(x) cout << #x << "=" << x << endl;
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl;

int N, D, M;
int a[1000300];

bool ok(int m) {
	int cm = 0, cd = 1;
	for (int i = 1; i <= M; i++) {
		if (cm < m) {
			if (a[i] > cd)
				cm = 1, cd = a[i];
			else {
				cm++;
				if (cd - a[i] > D)
					return 0;
			}
		}
		else {
			cm = 1, cd++;
			if (cd - a[i] > D)
				return 0;
		}
	}

	return 1;
}

signed main() {
	FAST;

	cin >> N >> D >> M;
	for (int i = 1; i <= M; i++)
		cin >> a[i];
	sort(a + 1, a + 1 + M);

	int l = 1, r = M, ans = M;
	while (l <= r) {
		int m = l + (r - l) / 2;
		if (ok(m)) ans = m, r = m - 1;
		else l = m + 1;
	}
	cout << ans << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 1348 KB Unexpected end of file - int32 expected
2 Incorrect 12 ms 1404 KB Unexpected end of file - int32 expected
3 Incorrect 11 ms 1312 KB Unexpected end of file - int32 expected
4 Incorrect 11 ms 1356 KB Unexpected end of file - int32 expected
5 Incorrect 12 ms 1356 KB Unexpected end of file - int32 expected
6 Incorrect 11 ms 1404 KB Unexpected end of file - int32 expected
7 Incorrect 11 ms 1304 KB Unexpected end of file - int32 expected
8 Incorrect 12 ms 1356 KB Unexpected end of file - int32 expected
9 Incorrect 14 ms 1356 KB Unexpected end of file - int32 expected
10 Incorrect 14 ms 1356 KB Unexpected end of file - int32 expected
11 Incorrect 17 ms 1484 KB Unexpected end of file - int32 expected
12 Incorrect 34 ms 2636 KB Unexpected end of file - int32 expected
13 Incorrect 49 ms 3792 KB Unexpected end of file - int32 expected
14 Incorrect 75 ms 5320 KB Unexpected end of file - int32 expected
15 Incorrect 83 ms 6144 KB Unexpected end of file - int32 expected
16 Incorrect 128 ms 7764 KB Unexpected end of file - int32 expected
17 Incorrect 147 ms 9140 KB Unexpected end of file - int32 expected
18 Incorrect 134 ms 9516 KB Unexpected end of file - int32 expected
19 Incorrect 150 ms 10820 KB Unexpected end of file - int32 expected
20 Incorrect 133 ms 9028 KB Unexpected end of file - int32 expected