# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1003354 | AtinaR | Job Scheduling (CEOI12_jobs) | C++14 | 264 ms | 34576 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n,d,m;
cin>>n>>d>>m;
pair<long long,long long> niza[m];
for(long long i=0; i<m; i++)
{
cin>>niza[i].first;
niza[i].second=i+1;
}
sort(niza,niza+m);
long long b=0,e=m+1;
long long res=0;
while(b<=e)
{
long long mid=(b+e)/2;
long long cnt=0;
long long day=1;
long long og=0;
bool flag=true;
for(long long i=0; i<m; i++)
{
cnt++;
if(cnt>mid || niza[i].first>day || niza[i].first-niza[og].first>d)
{
cnt=1;
og=i;
day++;
}
if(day-niza[i].first>d || day>n)
{
flag=false;
break;
}
}
if(flag)
{
res=mid;
e=mid-1;
}
else b=mid+1;
}
cout<<res<<endl;
long long cnt=0;
long long day=1;
long long og=0;
vector<long long> ress[n+1];
for(long long i=0; i<m; i++)
{
cnt++;
if(cnt>res || (niza[i].first>day && niza[i].first-niza[og].first>d))
{
cnt=1;
og=i;
day++;
}
ress[day].push_back(niza[i].second);
}
for(long long i=1; i<=n; i++)
{
for(auto x:ress[i])cout<<x<<" ";
cout<<0<<endl;
}
return 0;
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |