# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
677191 | sofija6 | Job Scheduling (CEOI12_jobs) | C++14 | 528 ms | 56060 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>
#define ll long long
#define MAXM 1000010
using namespace std;
ll n,d,m;
pair<ll,ll> a[MAXM];
bool Check(ll x)
{
vector<pair<ll,ll> > v[x+2];
ll cur=1;
for (ll i=1;i<=m;i++)
{
v[cur].push_back(a[i]);
cur++;
if (cur>x)
cur=1;
}
for (ll i=1;i<=x;i++)
{
cur=1;
for (ll j=0;j<v[i].size();j++)
{
if (cur<v[i][j].first)
cur=v[i][j].first;
if (cur-v[i][j].first>d)
return false;
cur++;
}
}
return true;
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> d >> m;
for (ll i=1;i<=m;i++)
{
cin >> a[i].first;
a[i].second=i;
}
sort(a+1,a+1+m);
ll l=1,r=m,mid,ans;
while (l<=r)
{
mid=(l+r)/2;
if (Check(mid))
{
ans=mid;
r=mid-1;
}
else
l=mid+1;
}
cout << ans << "\n";
vector<pair<ll,ll> > v[ans+2];
vector<ll> days[n+d+2];
ll cur=1;
for (ll i=1;i<=m;i++)
{
v[cur].push_back(a[i]);
cur++;
if (cur>ans)
cur=1;
}
for (ll i=1;i<=ans;i++)
{
cur=1;
for (ll j=0;j<v[i].size();j++)
{
if (cur<v[i][j].first)
cur=v[i][j].first;
days[cur].push_back(v[i][j].second);
cur++;
}
}
for (ll i=1;i<=n;i++)
{
for (ll j=0;j<days[i].size();j++)
cout << days[i][j] << " ";
cout << 0 << "\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |