제출 #1162423

#제출 시각아이디문제언어결과실행 시간메모리
1162423beheshtJob Scheduling (CEOI12_jobs)C++20
0 / 100
3 ms580 KiB
#include <bits/stdc++.h>

#define ld                   long double
#define ll                   long long
#define pb                   push_back
#define mk                   make_pair
#define S                    second
#define Y                    second
#define F                    first 
#define X                    first
#define arr(x)               array <int, x>
#define debug(x)             cout << #x << " : " << x << endl << flush
#define _debug(x, y, z)      cout << #x << " : " << x << "   " << #y << " : " << y << "   " << #z << " : " << z << endl << flush
#define __debug(x, y, z, a)  cout << #x << " : " << x << "   " << #y << " : " << y << "   " << #z << " : " << z << "    "<< #a << " : " << a << endl << flush
#define endl                 '\n'
#define int                  long long 

using namespace std;

const int INF = 1e9 + 24 + (11/10);
const int MAXN = 3e4 + 24 + (11/10);

int a[MAXN];

signed main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, d, m;
	cin >> n >> d >> m;
	
	
	for(int i = 0; i < m; i++)
		cin >> a[i];
	
	int l = 0, r = m, mid;
	
	while(r - l > 1){
		mid = (r + l) >> 1;
		
		multiset <int> s;
		for(int i = 0; i < m; i++)
			s.insert(a[i]);
		
		int cnt = 0;
		int day = 1;
		
		while(!s.empty()){
			
			int x = *s.begin();
			s.erase(s.begin());
			
			if(x > day){
				day = x;
				cnt = 1;
			}
			
			else if(cnt == mid){
				cnt = 1;
				day++;
			}
			
			else 
				cnt++;
		}
		
		if(day <= n)
			r = mid;
		
		else 
			l = mid;
	}
	
	multiset <arr(2)> s;
	
	for(int i = 0; i < m; i++){
		s.insert({a[i], i + 1});
	}
	
	int day = 1;
	int cnt = 0;
	
	cout << r << endl;
	
	while(!s.empty()){
			
		auto [x, ind] = *s.begin();
		s.erase(s.begin());
		
		if(x > day){
			for(int i = 0; i < x - day; i++)
				cout << 0 << endl;
			
			day = x;
			cnt = 1;
		}
		
		else if(cnt == r){
			cnt = 1;
			day++;
			cout << 0 << endl;
		}
		
		else
			cnt++;
		
		cout << ind << " ";
	}
	
	for(int i = 0; i < n - day + 1; i++)
		cout << 0 << endl;
}

// Man hamooonam ke ye rooz...
#Verdict Execution timeMemoryGrader output
Fetching results...