Submission #1062293

# Submission time Handle Problem Language Result Execution time Memory
1062293 2024-08-17T02:12:40 Z Kiet07 Job Scheduling (CEOI12_jobs) C++14
100 / 100
180 ms 17136 KB
#include<bits/stdc++.h>
using namespace std;
int n,m,d;
pair<int,int>a[1000005];
bool check(int x)
{
	int j=1;
	for(int days=1;days<=n;days++)
	{
		for(int i=1;i<=x;i++)
		{
			if(days>=a[j].first)
			{
				if(days<=a[j].first+d)
				{
					j++;
					if(j==m+1)return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				break;
			}
		}
	}
	return false;
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//freopen("TEST.inp","r",stdin);
	cin>>n>>d>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>a[i].first;
		a[i].second=i;
	}
	sort(a+1,a+m+1);
	int l=1,r=1000000,ans=r;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))
		{
			ans=mid;
			r=mid-1;
		}
		else
		{
			l=mid+1;
		}
	}
	cout<<ans<<'\n';
	int j=1;
	for(int days=1;days<=n;days++)
	{
		if(j<=m)
		{
			for(int i=1;i<=ans;i++)
			{
				if(days>=a[j].first&&days<=a[j].first+d)
				{
					cout<<a[j].second<<' ';
					j++;
					if(j==m+1)
					{
						break;
					}
				}
			}
		}
		cout<<0<<'\n';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 17 ms 3164 KB Output is correct
2 Correct 13 ms 3164 KB Output is correct
3 Correct 13 ms 3164 KB Output is correct
4 Correct 13 ms 3160 KB Output is correct
5 Correct 15 ms 3164 KB Output is correct
6 Correct 13 ms 3164 KB Output is correct
7 Correct 15 ms 3200 KB Output is correct
8 Correct 14 ms 3164 KB Output is correct
9 Correct 27 ms 3420 KB Output is correct
10 Correct 23 ms 3408 KB Output is correct
11 Correct 18 ms 3160 KB Output is correct
12 Correct 37 ms 3960 KB Output is correct
13 Correct 55 ms 6512 KB Output is correct
14 Correct 78 ms 7284 KB Output is correct
15 Correct 95 ms 8048 KB Output is correct
16 Correct 132 ms 10864 KB Output is correct
17 Correct 137 ms 14928 KB Output is correct
18 Correct 153 ms 15188 KB Output is correct
19 Correct 180 ms 17136 KB Output is correct
20 Correct 137 ms 14928 KB Output is correct