제출 #494019

#제출 시각아이디문제언어결과실행 시간메모리
494019js921Job Scheduling (CEOI12_jobs)C++14
0 / 100
402 ms13752 KiB
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>

using namespace std;

int N, D, M;
vector<pair<int,int>> jobs;

bool check_val(int a) {
	int day_num = 1;
	int counter = 0;
	for(int i = 0; i < M; i++) {
		if(jobs[i].first + D < day_num) {
			return false;
		} else {
			counter++;
			if(counter == a) {
				counter = 0;
				day_num++;
			}
		}
	}
	if(day_num-1 <= N) {
		return true;
	}
	return false;
}

int first_true() {
	int lo = 0, hi = 20;
	while(lo < hi) {
		int mid = lo + (hi - lo)/2;
		if(check_val(mid) == true) {
			hi = mid;
		} else {
			lo = mid+1;
		}
	}
	return lo;
}

int main() {

	cin >> N >> D >> M;
	for(int i = 0; i < M; i++) {
		int x; cin >> x;
		jobs.push_back(make_pair(x, i));
		//cout << jobs[i].first << " " << jobs[i].second << endl;
	}
	sort(jobs.begin(), jobs.end());

	int y = first_true();
	cout << y << endl;

	int day_num = 1, counter = 0;
	for(int i = 0; i < M; i++) {
		cout << jobs[i].second+1 << " ";
		counter++;
		if(counter == y) {
			counter = 0;
			day_num++;
			cout << 0 << endl;
		}
	}

	/*for(int i = 0; i < M; i++) {
		cout << jobs[i].first << " " << jobs[i].second << endl;
	}*/

	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...