# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
694188 | vjudge1 | Job Scheduling (CEOI12_jobs) | C++17 | 130 ms | 33808 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 pb push_back
#define all(s) s.begin(), s.end()
#ifndef LOCALDEBUG
#define LOCALDEBUG false
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
struct request
{
int day, id;
};
int n, d, m;
vector<request> requestsOnDay[(int)1e6 + 1];
bool check(int machines)
{
queue<request> active;
for (int i = 1; i <= n; i++)
{
// get new requests
for (request r : requestsOnDay[i])
active.push(r);
int mm = machines;
while (!active.empty() && mm--)
{
int cur = active.front().day;
if (cur + d < i)
return false;
else
active.pop();
}
}
return active.size() == 0;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> d >> m;
for (int i = 0; i < m; i++)
{
int x;
cin >> x;
requestsOnDay[x].pb({x, i});
}
int lo = 1, hi = 1e6;
while (lo < hi)
{
int mid = (lo + hi) / 2;
if (check(mid))
hi = mid - 1;
else
lo = mid + 1;
}
cout << lo << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |