제출 #522358

#제출 시각아이디문제언어결과실행 시간메모리
522358Yazan_AlattarJob Scheduling (CEOI12_jobs)C++14
15 / 100
165 ms1836 KiB
#include <bits/stdc++.h>

using namespace std;
const int M = 100005;
#define F first
#define S second

int n, d, m;
pair <int,int> a[M];

bool check(int mid)
{
	int pos = 1;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= mid && pos <= m; ++j, ++pos) if(i - a[pos].F > d) return 0;
	return (pos == m + 1);
}

int main()
{
	cin >> n >> d >> m;
	for(int i = 1; i <= m; ++i) cin >> a[i].F, a[i].S = i;
	sort(a + 1, a + m + 1);
	int l = 1, r = m + 1;
	while(l < r){
		int mid = (l + r) / 2;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << r << endl;
	int pos = 1;
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= r && pos <= m; ++j, ++pos) cout << a[pos].S << " ";
		cout << 0 << endl;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...