# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
747771 | Hyojin | Job Scheduling (CEOI12_jobs) | C++17 | 1083 ms | 17452 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;
#define bit(n,i) ((n>>i)&1)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define ep emplace_back
#define pii pair<int,int>
#define piii pair<int,pii>
#define fi first
#define se second
#define ll long long
#define deb(x) cerr << #x << ' ' << x << '\n'
const int base=31;
const int MOD=1e9+7;
const int N=1e6+5;
void setIO(const string &NAME)
{
if (NAME.size())
{
freopen((NAME+".inp").c_str(),"r",stdin);
freopen((NAME+".out").c_str(),"w",stdout);
}
}
int n,m,d;
pii a[N];
bool check(int x)
{
int curJob=1;
for (int days=1;days<=n;days++)
{
for (int machine=1;machine<=x;machine++)
{
if (a[curJob].fi>days) continue;
if (a[curJob].fi+d>=days) curJob++;
if (curJob==m) return true;
}
}
return false;
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifdef izumiShiho
setIO("input");
#endif //izumiShiho
cin>>n>>d>>m;
for (int i=1;i<=m;i++)
{
cin>>a[i].fi;
a[i].se=i;
}
sort(a+1,a+m+1);
int l=1,r=m;
while (l<=r)
{
int mid=l+r>>1;
if (check(mid)) r=mid-1;
else l=mid+1;
}
cout<<r+1<<"\n";
vector<vector<int>>ans;
ans.resize(n+1);
int x=r+1;
int curJob=1;
for (int days=1;days<=n;days++)
{
for (int machine=1;machine<=x;machine++)
{
if (a[curJob].fi>days) continue;
if (a[curJob].fi+d>=days)
{
ans[days].pb(a[curJob].se);
curJob++;
}
if (curJob==m) break;
}
if (curJob==m) break;
}
for (int i=1;i<=n;i++)
{
for (auto x:ans[i]) cout<<x<<' ';
cout<<0<<"\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |