# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
674275 | thienbao1602 | Job Scheduling (CEOI12_jobs) | C++17 | 333 ms | 64900 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 fi first
#define se second
#define pb push_back
using namespace std;
const int N = 1e5 + 55;
int days, delay, number_jobs;
vector<pair<ll, ll>> jobs;
vector<ll> ans[N];
bool check(ll machine)
{
for(int i=0; i<days; i++)
{
ans[i].clear();
}
ll id_job = 0;
for(int i=0; i<days; i++)
{
int cur_machine = 0;
while(cur_machine < machine)
{
if (jobs[id_job].fi > i + 1) break;
if (jobs[id_job].fi <= delay + i + 1)
{
ans[i].pb(jobs[id_job].se);
id_job++, cur_machine++;
} else return false;
if (id_job == number_jobs) return true;
}
}
return (id_job == number_jobs);
}
ll bs(ll l, ll r)
{
while(l < r)
{
ll m = (l + r) >> 1;
if (check(m))
{
r = m;
} else
{
l = m + 1;
}
}
check(l);
return l;
}
void solve()
{
cin >> days >> delay >> number_jobs;
for(int i=0; i<number_jobs; i++)
{
ll x;
cin >> x;
jobs.pb({x, i + 1});
}
sort(jobs.begin(), jobs.end());
cout << bs(1, days) << "\n";
for(int i=0; i<days; i++)
{
ans[i].pb(0);
}
for(int i=0; i<days; i++)
{
for(int j=0; j<(int)ans[i].size(); j++)
{
cout << ans[i][j] << " ";
}
cout << "\n";
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |