Submission #1100348

# Submission time Handle Problem Language Result Execution time Memory
1100348 2024-10-13T14:41:50 Z prabandh Job Scheduling (CEOI12_jobs) C++17
0 / 100
124 ms 15944 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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 2128 KB Output isn't correct
2 Incorrect 8 ms 2128 KB Output isn't correct
3 Incorrect 7 ms 2128 KB Output isn't correct
4 Incorrect 7 ms 2128 KB Output isn't correct
5 Incorrect 8 ms 2300 KB Output isn't correct
6 Incorrect 8 ms 2128 KB Output isn't correct
7 Incorrect 8 ms 2128 KB Output isn't correct
8 Incorrect 9 ms 2128 KB Output isn't correct
9 Incorrect 17 ms 3408 KB Unexpected end of file - int32 expected
10 Incorrect 16 ms 3408 KB Unexpected end of file - int32 expected
11 Incorrect 15 ms 1872 KB Unexpected end of file - int32 expected
12 Incorrect 27 ms 3408 KB Unexpected end of file - int32 expected
13 Incorrect 39 ms 5160 KB Unexpected end of file - int32 expected
14 Incorrect 55 ms 6736 KB Unexpected end of file - int32 expected
15 Incorrect 64 ms 8272 KB Output isn't correct
16 Incorrect 80 ms 9808 KB Unexpected end of file - int32 expected
17 Incorrect 94 ms 11496 KB Unexpected end of file - int32 expected
18 Incorrect 105 ms 13128 KB Unexpected end of file - int32 expected
19 Incorrect 124 ms 15944 KB Unexpected end of file - int32 expected
20 Incorrect 94 ms 11488 KB Unexpected end of file - int32 expected