답안 #494019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494019 2021-12-13T18:24:40 Z js921 Job Scheduling (CEOI12_jobs) C++14
0 / 100
402 ms 13752 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 1744 KB Output isn't correct
2 Incorrect 40 ms 1720 KB Output isn't correct
3 Incorrect 33 ms 1776 KB Output isn't correct
4 Incorrect 33 ms 1716 KB Output isn't correct
5 Incorrect 37 ms 1720 KB Output isn't correct
6 Incorrect 37 ms 1796 KB Output isn't correct
7 Incorrect 34 ms 1748 KB Output isn't correct
8 Incorrect 37 ms 1680 KB Output isn't correct
9 Incorrect 42 ms 1720 KB Output isn't correct
10 Incorrect 51 ms 1676 KB Output isn't correct
11 Incorrect 45 ms 1704 KB Output isn't correct
12 Incorrect 91 ms 3384 KB Output isn't correct
13 Incorrect 160 ms 4680 KB Output isn't correct
14 Incorrect 212 ms 6232 KB Output isn't correct
15 Incorrect 256 ms 7784 KB Output isn't correct
16 Incorrect 289 ms 9356 KB Output isn't correct
17 Incorrect 344 ms 10732 KB Output isn't correct
18 Incorrect 374 ms 12228 KB Output isn't correct
19 Incorrect 402 ms 13752 KB Output isn't correct
20 Incorrect 378 ms 10668 KB Output isn't correct