# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
565296 | PranjalChandra | Job Scheduling (CEOI12_jobs) | C++14 | 1096 ms | 19496 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>
#include <limits.h>
#define ll long long
#define ull unsigned long long
#define INF 1000000007
using namespace std;
ll days, D, tasks;
vector<pair<ll, ll>> schdl;
vector<vector<ll>> ans;
void ansPrint(ll mchnPoss)
{
ll day = 1;
for (ll i = 1; i <= tasks; i = i + mchnPoss, ++day)
{
vector<ll> tmp;
for (ll j = i; j < i + mchnPoss; j++)
{
tmp.push_back(schdl[j].second);
ll slot = schdl[j].first + abs(schdl[j].first - day);
}
tmp.push_back(0);
ans.push_back(tmp);
}
}
bool ok(ll mchnPoss)
{
ll day = 1;
for (ll i = 1; i <= tasks; i = i + mchnPoss, ++day)
{
for (ll j = i; j < i + mchnPoss; j++)
{
ll slot = schdl[j].first + abs(schdl[j].first - day);
if (abs(slot - schdl[j].first) > D)
return false;
}
}
return true;
}
int main()
{
cin >> days >> D >> tasks;
schdl.push_back({-1, -1});
for (ll i = 1; i <= tasks; i++)
{
ll x;
cin >> x;
schdl.push_back({x, i});
}
sort(schdl.begin(), schdl.end());
ll l = 0;
ll r = 1;
while (ok(r) != true)
r = r * 2;
while (r > l + 1)
{
ll m = l + (r - l) / 2;
if (ok(m))
r = m;
else
l = m;
}
ll machReq = r;
ansPrint(machReq);
cout << r << "\n";
for (auto v : ans)
{
for (auto e : v)
cout << e << " ";
cout << "\n";
}
for (ll i = 0; i < days - ans.size(); ++i)
cout << 0 << "\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |