답안 #640064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
640064 2022-09-13T12:48:04 Z Trisanu_Das Job Scheduling (CEOI12_jobs) C++17
100 / 100
399 ms 13724 KB
#include <bits/stdc++.h>
using namespace std;
const int M = 1000005;
#define ff first
#define ss second
 
int n, d, m;
pair <int,int> tasks[M];
 
bool check(int mid){
	int pos = 1;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= mid && pos <= m && tasks[pos].ff <= i; ++j) if(i - tasks[pos++].ff > d) return false;
	return (pos == m + 1);
}
 
int main(){
	cin >> n >> d >> m;
	for(int i = 1; i <= m; ++i) cin >> tasks[i].ff, tasks[i].ss = i;
	sort(tasks + 1, tasks + 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 << '\n';
	int pos = 1;
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= r && pos <= m && tasks[pos].ff <= i; ++j, ++pos) cout << tasks[pos].ss << ' ';
		cout << 0 << '\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1580 KB Output is correct
2 Correct 27 ms 1604 KB Output is correct
3 Correct 30 ms 1672 KB Output is correct
4 Correct 43 ms 1660 KB Output is correct
5 Correct 40 ms 1612 KB Output is correct
6 Correct 28 ms 1560 KB Output is correct
7 Correct 33 ms 1576 KB Output is correct
8 Correct 28 ms 1612 KB Output is correct
9 Correct 42 ms 1776 KB Output is correct
10 Correct 42 ms 1824 KB Output is correct
11 Correct 38 ms 1620 KB Output is correct
12 Correct 75 ms 3136 KB Output is correct
13 Correct 130 ms 4556 KB Output is correct
14 Correct 168 ms 6108 KB Output is correct
15 Correct 195 ms 7640 KB Output is correct
16 Correct 246 ms 9228 KB Output is correct
17 Correct 322 ms 10492 KB Output is correct
18 Correct 369 ms 11976 KB Output is correct
19 Correct 399 ms 13724 KB Output is correct
20 Correct 297 ms 10560 KB Output is correct