# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
441761 | Yuisuyuno | Job Scheduling (CEOI12_jobs) | C++14 | 325 ms | 34756 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.
//Nguyen Huu Hoang Minh
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define N 1000001
#define ii pair<int, int>
#define vi vector<int>
#define int long long
using namespace std;
const int minf = -1e10;
int n, m, d;
vector<ii> a;
void readfile()
{
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin >> n >> d >> m;
a.resize(m+1);
for(int i=1; i<=m; i++){
cin >> a[i].fi;
a[i].se = i;
}
sort(a.begin(),a.end());
}
bool ok(int machine){
int endT[machine] = {0};
int delays = minf;
for(int i=1, cur=0; i<=m; i++, cur++){
if (cur==machine) cur=0;
if (endT[cur]+1 > a[i].first){
endT[cur]++;
delays = max(delays,endT[cur]-a[i].fi);
}
else endT[cur]=a[i].fi;
}
return delays <= d;
}
vector<int> res[100012];
void proc()
{
int l = 0, r = m, ans;
while (r >= l){
int mid = (l+r)/2;
if (ok(mid)){
r = mid-1;
ans=mid;
}
else l = mid+1;
}
cout << ans << '\n';
int endT[ans+1] = {0};
for(int i=1, cur=0; i<=m; i++, cur++){
if (cur==ans) cur=0;
endT[cur]=max(a[i].fi,endT[cur]+1);
res[endT[cur]].pb(a[i].se);
}
for(int i=1; i<=n; i++){
for(int x : res[i]) cout << x << ' ';
cout << "0\n";
}
}
signed main()
{
readfile();
proc();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |