답안 #1100342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1100342 2024-10-13T14:36:46 Z prabandh Job Scheduling (CEOI12_jobs) C++14
10 / 100
174 ms 22324 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve()
{
	int n,d,m;
	cin>>n>>d>>m;
	vector<int> a(n,0);
	vector<pair<int,int>> jobs(m);
	for(int i=0;i<m;i++)
	{
		int x;
		cin>>x;
		a[x-1]++;
		jobs[i] = {x-1,i+1};
	}
	sort(jobs.begin(),jobs.end());
	auto f = [&](int x)
	{
		vector<int> b = vector<int>(a.begin(),a.end());
		int i = 0;
		int day = 0;
		while(i<n)
		{
			if(i<=day-d-1) return false;
			int tot = x;
			while(i<n && tot-b[i]>=0)
			{
				tot = tot-b[i];
				i++;
			}
			b[i] -= tot;
			day++;
		}
		return true;
	};
	int l=1; int r=m;
	int ans = -1;
	while(l<=r)
	{
		int mid = (l+r)/2;
		if(f(mid))
		{
			ans = mid;
			r = mid-1;
		}
		else l=mid+1;
	}
	cout<<ans<<endl;
	int j = 0;
	while(j<m)
	{
		int tot = ans;
		while(j<m && tot>0)
		{
			cout<<jobs[j].second<<" ";
			tot--;
			j++;
		}
		cout<<0<<endl;
	}
	return;
}
int32_t main() 
{
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int T;
  //cin>>T;
  T = 1;
  while(T--)
  {
    solve();
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 2640 KB Output isn't correct
2 Incorrect 12 ms 2640 KB Output isn't correct
3 Incorrect 12 ms 2640 KB Output isn't correct
4 Incorrect 12 ms 2640 KB Output isn't correct
5 Incorrect 12 ms 2624 KB Output isn't correct
6 Incorrect 12 ms 2640 KB Output isn't correct
7 Incorrect 13 ms 2676 KB Output isn't correct
8 Incorrect 12 ms 2652 KB Output isn't correct
9 Incorrect 21 ms 4160 KB Unexpected end of file - int32 expected
10 Incorrect 21 ms 4160 KB Unexpected end of file - int32 expected
11 Incorrect 20 ms 2384 KB Unexpected end of file - int32 expected
12 Correct 39 ms 4680 KB Output is correct
13 Incorrect 56 ms 6940 KB Unexpected end of file - int32 expected
14 Correct 92 ms 9544 KB Output is correct
15 Incorrect 98 ms 11624 KB Output isn't correct
16 Incorrect 130 ms 14016 KB Unexpected end of file - int32 expected
17 Incorrect 142 ms 16200 KB Unexpected end of file - int32 expected
18 Incorrect 158 ms 18440 KB Unexpected end of file - int32 expected
19 Incorrect 174 ms 22324 KB Unexpected end of file - int32 expected
20 Incorrect 147 ms 16200 KB Unexpected end of file - int32 expected