Submission #502063

#TimeUsernameProblemLanguageResultExecution timeMemory
502063forevpurityJob Scheduling (CEOI12_jobs)C++14
0 / 100
256 ms13680 KiB
#include <bits/stdc++.h>
	
using namespace std;


int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	//freopen("socdist.in", "r", stdin);
	//freopen("socdist.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].second = i;
	}
	sort(v.begin(), v.end());
	int l = 1, r = 1e6;
	while(l < r){
		int x = l + (r - l)/2;
		bool check = 1;
		int p = 0;
		for (int i = 1; i <= n; i++){
			int cur = 0;
			while (p < m && v[p].first <= i && cur < x){
				if (i - v[p].first > d) check = 0;
				p++;
				cur++;
			}
		}
		if (check) r = x;
		else l = x + 1;
	}
	int machines = l;
	int p = 0;
	for (int i = 1; i <= n; i++){
		int cur = 0;
		while (p < m && v[p].first <= i && cur < machines){
			cout << v[p].second + 1 << " ";
			p++;
			cur++;
		}
		if (i == n){
			cout << 0;
			continue;
		}
		cout << 0 << '\n';
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...