답안 #416457

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
416457 2021-06-02T12:13:02 Z shubham20_03 Job Scheduling (CEOI12_jobs) C++17
10 / 100
181 ms 18456 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;
#define ff first
#define ss second
#define pb push_back

int N, D, M;
vector<vector<int>> a;

bool ok(int m) {
	vector<int> av(N + 1, m);
	for (int i = 1; i <= N - D; i++) {
		int jbs = a[i].size();
		for (int j = i; j <= i + D && jbs; j++) {
			if (av[j] >= jbs) {
				av[j] -= jbs;
				jbs = 0;
			}
			else {
				jbs -= av[j];
				av[j] = 0;
			}
		}
		if (jbs) return 0;
	}
	return 1;
}

void show(int m) {
	for (int i = 1, cd = 1; i <= N; i++) {
		int tm = m;
		while (tm--) {
			while (cd <= N && a[cd].empty()) cd++;
			if (cd > N) return;
			cout << a[cd].back() << " ";
			a[cd].pop_back();
		}
		cout << "0\n";
	}
}

signed main() {
	FAST;

	cin >> N >> D >> M;
	a = vector<vector<int>>(N + 1);
	for (int i = 1; i <= M; i++) {
		int x; cin >> x;
		a[x].pb(i);
	}

	int l = 1, r = 1e6 + 7, 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 << "\n";
	show(ans);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 1992 KB Unexpected end of file - int32 expected
2 Incorrect 18 ms 1996 KB Unexpected end of file - int32 expected
3 Incorrect 19 ms 1992 KB Unexpected end of file - int32 expected
4 Incorrect 18 ms 1976 KB Unexpected end of file - int32 expected
5 Incorrect 19 ms 1992 KB Unexpected end of file - int32 expected
6 Incorrect 19 ms 1992 KB Unexpected end of file - int32 expected
7 Incorrect 19 ms 1964 KB Unexpected end of file - int32 expected
8 Incorrect 19 ms 1992 KB Unexpected end of file - int32 expected
9 Incorrect 24 ms 5236 KB Unexpected end of file - int32 expected
10 Incorrect 23 ms 5180 KB Unexpected end of file - int32 expected
11 Incorrect 21 ms 2016 KB Unexpected end of file - int32 expected
12 Correct 40 ms 3676 KB Output is correct
13 Incorrect 60 ms 6628 KB Unexpected end of file - int32 expected
14 Correct 110 ms 8384 KB Output is correct
15 Incorrect 111 ms 9724 KB Unexpected end of file - int32 expected
16 Incorrect 150 ms 12376 KB Unexpected end of file - int32 expected
17 Incorrect 172 ms 15536 KB Unexpected end of file - int32 expected
18 Incorrect 160 ms 14888 KB Unexpected end of file - int32 expected
19 Incorrect 181 ms 18456 KB Unexpected end of file - int32 expected
20 Incorrect 170 ms 15428 KB Unexpected end of file - int32 expected