# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
899646 | ivaziva | Job Scheduling (CEOI12_jobs) | C++14 | 340 ms | 28200 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;
long long n,d,m;
vector<pair<pair<long long,long long>,long long>> vec;
bool check(long long mid)
{
long long dan=1;
bool da=true;
long long poz=0;
while (dan<=n)
{
if (!da) break;
long long br=1;
while (br<=mid and poz<vec.size())
{
long long pocetak=vec[poz].first.first;
long long kraj=vec[poz].first.second;
if (dan>=pocetak and dan<=kraj) {poz++;br++;}
else if (dan>kraj) {da=false;break;}
else if (dan<pocetak) break;
}
dan++;
}
return da;
}
void resenje(long long rez)
{
long long dan=1;
long long poz=0;
while (dan<=n)
{
long long br=1;
while (br<=rez and poz<vec.size())
{
long long pocetak=vec[poz].first.first;
long long kraj=vec[poz].first.second;
if (dan>=pocetak and dan<=kraj)
{
cout<<vec[poz].second<<" ";
poz++;br++;
}
else if (dan<pocetak) break;
}
cout<<0<<endl;dan++;
}
}
int main()
{
ios_base::sync_with_stdio(false);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>d>>m;
for (long long i=1;i<=m;i++)
{
long long x; cin>>x;
vec.push_back({{x,x+d},i});
}
sort(vec.begin(),vec.end());
long long l=1;
long long r=m;
long long rez=-1;
while (l<=r)
{
long long mid=(l+r)/2;
if (check(mid)) {rez=mid;r=mid-1;}
else l=mid+1;
}
cout<<rez<<endl;
resenje(rez);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |