# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
817631 | n3rm1n | Job Scheduling (CEOI12_jobs) | C++17 | 146 ms | 11344 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 endl '\n'
using namespace std;
const int MAXN = 1e6 + 10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, d, m;
vector < pair < int, int > > g;
void read()
{
cin >> n >> d >> m;
int x;
for (int i = 1; i <= m; ++ i)
{
cin >> x;
g.push_back({x, i});
}
sort(g.begin(), g.end());
}
bool check(int x)
{
int i = 0, moment = 0;
while (i < g.size())
{
moment ++;
int j = i;
while(j < g.size() && j - i + 1 <= x && g[j].first <= moment)
{
j ++;
}
i = j;
}
return (moment <= n);
}
int main()
{
speed();
read();
int left = 1, right = m, mid, ans = m+1;
while(left <= right)
{
mid = (left + right)/2;
if(check(mid))
{
ans = mid;
right = mid - 1;
}
else left = mid + 1;
}
cout << ans << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |