# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1027942 | vjudge1 | Job Scheduling (CEOI12_jobs) | C++17 | 300 ms | 26836 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(0); cin.tie(0); cout.tie(0);
int n, docnenje, m;
cin>>n>>docnenje>>m;
pair<int, int>a[m];
for(int i=0; i<m; i++)
{
cin>>a[i].first;
a[i].second=i;
}
sort(a, a+m);
int l=0, r=m-1;
vector<vector<int>>sol(n+1);
while(r-l>1)
{
vector<vector<int>>rez(n+1);
int mid=(l+r)/2;
int index=0;
bool kiki1=0;
bool found=0;
for(int i=1; i<=n && !found; i++)
{
bool kiki=0;
for(int j=0; j<mid; j++)
{
if(a[index].first+docnenje<i)
{
kiki=1;
break;
}
if(a[index].first>i)
break;
index++;
rez[i].push_back(a[index].second);
if(index==m)
{
sol=rez;
found=1;
break;
}
}
if(kiki)
{
kiki1=1;
break;
}
}
if(kiki1)
l=mid;
else
r=mid;
}
cout<<r<<"\n";
for(int i=1; i<=n; i++)
{
for(int j=0; j<sol[i].size(); j++)
cout<<sol[i][j]+1<<" ";
cout<<"\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |