답안 #1062290

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1062290 2024-08-17T01:43:25 Z Kiet07 Job Scheduling (CEOI12_jobs) C++14
25 / 100
1000 ms 65536 KB
#include<bits/stdc++.h>
using namespace std;
int n,m,d;
bool check(int x,multiset<pair<int,int>>ms)
{
	for(int days=1;days<=n;days++)
	{
		for(int i=1;i<=x;i++)
		{
			if(days<=ms.begin()->first+d)
			{
				ms.erase(ms.begin());
				if(ms.empty())
				{
					return true;
				}
			}
			else
			{
				return false;
			}
		}
	}
	if(ms.empty())
	{
		return true;
	}
	else
	{
		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;
	multiset<pair<int,int>>ms;
	for(int i=1;i<=m;i++)
	{
		int x; cin>>x;
		ms.insert({x,i});
	}
	int l=1,r=1000000,ans=r;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid,ms))
		{
			ans=mid;
			r=mid-1;
		}
		else
		{
			l=mid+1;
		}
	}
	cout<<ans<<'\n';
	for(int days=1;days<=n;days++)
	{
		if(!ms.empty())
		{
			for(int i=1;i<=ans;i++)
			{
				if(days<=ms.begin()->first+d)
				{
					cout<<ms.begin()->second<<' ';
					ms.erase(ms.begin());
					if(ms.empty())
					{
						break;
					}
				}
			}
		}
		cout<<0<<'\n';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 78 ms 10672 KB Output isn't correct
2 Incorrect 80 ms 10652 KB Output isn't correct
3 Incorrect 79 ms 10576 KB Output isn't correct
4 Incorrect 79 ms 10580 KB Output isn't correct
5 Incorrect 78 ms 10580 KB Output isn't correct
6 Incorrect 80 ms 10652 KB Output isn't correct
7 Incorrect 77 ms 10576 KB Output isn't correct
8 Incorrect 77 ms 10580 KB Output isn't correct
9 Correct 89 ms 10852 KB Output is correct
10 Correct 92 ms 10836 KB Output is correct
11 Correct 100 ms 10724 KB Output is correct
12 Correct 244 ms 21468 KB Output is correct
13 Correct 403 ms 31572 KB Output is correct
14 Runtime error 708 ms 42648 KB Memory limit exceeded
15 Execution timed out 1014 ms 52636 KB Time limit exceeded
16 Execution timed out 1048 ms 59472 KB Time limit exceeded
17 Runtime error 399 ms 65536 KB Execution killed with signal 9
18 Runtime error 441 ms 65536 KB Execution killed with signal 9
19 Runtime error 488 ms 65536 KB Execution killed with signal 9
20 Runtime error 393 ms 65536 KB Execution killed with signal 9