답안 #670909

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
670909 2022-12-11T10:11:46 Z canhnam357 Job Scheduling (CEOI12_jobs) C++17
100 / 100
284 ms 21432 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("angry.in", "r", stdin);
	//freopen("angry.out", "w", stdout);
	int n, d, m;
	cin >> n >> d >> m;
	vector<pair<int, int>> v(m);
	for (int i = 0; i < m; i++)
	{
		cin >> v[i].first;
		v[i].first += d;
		v[i].second = i + 1;
	}
	sort(v.begin(), v.end());
	int l = 0, r = m + 1;
	auto can = [&](int mid)
	{
		int pos = 0;
		for (int i = 1; pos < m; i++)
		{
			if (v[pos].first < i) return false;
			for (int j = 0; j < mid && pos < m; j++)
			{
				if (v[pos].first - d <= i && v[pos].first >= i) pos++;
				else break;
			}
		}
		return true;
	};
	while (r - l > 1)
	{
		int mid = (l + r) >> 1;
		if (can(mid)) r = mid;
		else l = mid;
	}
	cout << r << '\n';
	int pos = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < r && pos < m; j++)
		{
			if (v[pos].first - d <= i && v[pos].first >= i) pos++, cout << v[pos - 1].second << ' ';
			else break;
		}
		cout << 0 << '\n';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 2784 KB Output is correct
2 Correct 20 ms 2772 KB Output is correct
3 Correct 19 ms 2712 KB Output is correct
4 Correct 21 ms 2696 KB Output is correct
5 Correct 20 ms 2700 KB Output is correct
6 Correct 18 ms 2704 KB Output is correct
7 Correct 21 ms 2684 KB Output is correct
8 Correct 22 ms 2760 KB Output is correct
9 Correct 32 ms 2900 KB Output is correct
10 Correct 31 ms 2916 KB Output is correct
11 Correct 29 ms 2756 KB Output is correct
12 Correct 51 ms 5360 KB Output is correct
13 Correct 80 ms 7560 KB Output is correct
14 Correct 119 ms 9904 KB Output is correct
15 Correct 136 ms 12088 KB Output is correct
16 Correct 173 ms 14456 KB Output is correct
17 Correct 194 ms 16632 KB Output is correct
18 Correct 224 ms 18968 KB Output is correct
19 Correct 284 ms 21432 KB Output is correct
20 Correct 188 ms 16760 KB Output is correct