답안 #63344

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
63344 2018-08-01T14:01:45 Z bazsi700 Job Scheduling (CEOI12_jobs) C++14
40 / 100
338 ms 29312 KB
#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

//15:55 -1 óra? fél?

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,d,m;
	cin >> n >> d >> m;
	vi jobs(n+1,0);
	for(int i = 0; i < m; i++) {
		int x;
		cin >> x;
		jobs[x]++;
	}
	int l = 1;
	int r = m;
	while(l < r) {
		int mid = (l+r)/2;
		queue<int> todo;
		bool good = true;
		for(int i = 1; i <= n; i++) {
			for(int j = 0; j < jobs[i]; j++) {
				todo.push(i);
			}
			for(int j = 0; j < mid; j++) {
				if(todo.empty()) {
					break;
				}
				int day = todo.front();
				todo.pop();
				if(day+d < i) {
					good = false;
					break;
				}
			}
			if(!good) {
				break;
			}
		}
		if(good) {
			r = mid;
		} else {
			l = mid+1;
		}
	}
	cout << l << "\n";
	queue<int> todo;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < jobs[i]; j++) {
			todo.push(i);
		}
		for(int j = 0; j < l; j++) {
			if(todo.empty()) {
				break;
			}
			int day = todo.front();
			todo.pop();
			cout << day << " ";
		}
		cout << "0\n";
	}
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Partially correct 34 ms 1504 KB Partially correct
2 Partially correct 32 ms 1772 KB Partially correct
3 Partially correct 34 ms 2092 KB Partially correct
4 Partially correct 34 ms 2516 KB Partially correct
5 Partially correct 33 ms 2816 KB Partially correct
6 Partially correct 31 ms 3108 KB Partially correct
7 Partially correct 33 ms 3544 KB Partially correct
8 Partially correct 38 ms 3752 KB Partially correct
9 Partially correct 37 ms 4300 KB Partially correct
10 Partially correct 42 ms 4544 KB Partially correct
11 Partially correct 38 ms 4544 KB Partially correct
12 Partially correct 80 ms 5700 KB Partially correct
13 Partially correct 88 ms 7100 KB Partially correct
14 Partially correct 126 ms 9936 KB Partially correct
15 Partially correct 187 ms 11556 KB Partially correct
16 Partially correct 219 ms 15636 KB Partially correct
17 Partially correct 298 ms 19348 KB Partially correct
18 Partially correct 338 ms 22248 KB Partially correct
19 Partially correct 303 ms 26432 KB Partially correct
20 Partially correct 241 ms 29312 KB Partially correct