Submission #938083

# Submission time Handle Problem Language Result Execution time Memory
938083 2024-03-04T19:25:14 Z TAhmed33 Job Scheduling (CEOI12_jobs) C++
0 / 100
95 ms 3952 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 25;
int n, d, m;
int a[MAXN];
bool check (int x) {
	bool flag = 1;
	int ptr = 1;
	for (int day = 1; day <= n; day++) {
		int cnt = 0;
		while (ptr <= m && a[ptr] <= day && cnt + 1 <= x) {
			flag &= day <= a[ptr] + d;
			ptr++; cnt++;
		} 
	}
	flag &= ptr == m + 1;
	return flag;
}
void cringe () {
	for (int i = 1; i <= n; i++) cout << 0 << endl;
}
int main () {
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("rand", "r", stdin);
	cin >> n >> d >> m;
	for (int i = 1; i <= m; i++) cin >> a[i];
	sort(a + 1, a + m + 1);
	int l = 1, r = m - 1, ans = m;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check(mid)) {
			r = mid - 1; ans = mid;
		} else {
			l = mid + 1;
		}
	}
	cout << ans << '\n';
	//cringe();
}
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 2648 KB Unexpected end of file - int32 expected
2 Incorrect 7 ms 2516 KB Unexpected end of file - int32 expected
3 Incorrect 7 ms 2652 KB Unexpected end of file - int32 expected
4 Incorrect 8 ms 2652 KB Unexpected end of file - int32 expected
5 Incorrect 7 ms 2652 KB Unexpected end of file - int32 expected
6 Incorrect 7 ms 2676 KB Unexpected end of file - int32 expected
7 Incorrect 7 ms 2648 KB Unexpected end of file - int32 expected
8 Incorrect 7 ms 2652 KB Unexpected end of file - int32 expected
9 Incorrect 10 ms 2652 KB Unexpected end of file - int32 expected
10 Incorrect 10 ms 2652 KB Unexpected end of file - int32 expected
11 Incorrect 11 ms 2652 KB Unexpected end of file - int32 expected
12 Incorrect 22 ms 2692 KB Unexpected end of file - int32 expected
13 Incorrect 34 ms 2652 KB Unexpected end of file - int32 expected
14 Incorrect 49 ms 2648 KB Unexpected end of file - int32 expected
15 Incorrect 53 ms 2652 KB Unexpected end of file - int32 expected
16 Incorrect 74 ms 2648 KB Unexpected end of file - int32 expected
17 Incorrect 87 ms 3196 KB Unexpected end of file - int32 expected
18 Incorrect 88 ms 3576 KB Unexpected end of file - int32 expected
19 Incorrect 95 ms 3952 KB Unexpected end of file - int32 expected
20 Incorrect 86 ms 2948 KB Unexpected end of file - int32 expected