Submission #1203980

#TimeUsernameProblemLanguageResultExecution timeMemory
1203980PlayVoltzJob Scheduling (CEOI12_jobs)C++20
100 / 100
279 ms31236 KiB
#include <cstdio>
#include <stdio.h>
#include <stdbool.h>
#include <iostream>
#include <map>
#include <vector>
#include <climits>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <cctype>
#include <bitset>
#include <iomanip>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;

#define int long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n, d, m;
vector<pii> vect;
vector<vector<int> > ans;

bool check(int mid){
	ans.clear();
	ans.resize(n);
	int p=0;
	for (int i=0, j; i<n; ++i){
		for (j=p; j<min(m, p+mid); ++j){
			if (vect[j].fi<=i){
				if (i-vect[j].fi>d)return 0;
				else ans[i].pb(vect[j].se);
			}
			else break;
		}
		p=j;
	}
	return (p==m);
}

int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>d>>m;
	vect.resize(m);
	for (int i=0; i<m; ++i)cin>>vect[i].fi, --vect[i].fi, vect[i].se=i+1;
	sort(vect.begin(), vect.end());
	int low=0, high=m+1;
	while (low+1<high){
		int mid=(low+high)/2;
		if (check(mid))high=mid;
		else low=mid;
	}
	check(high);
	cout<<high<<"\n";
	for (auto a:ans){
		for (auto b:a)cout<<b<<" ";
		cout<<"0\n";
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...