# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
439951 | a11155 | Job Scheduling (CEOI12_jobs) | C++14 | 250 ms | 3908 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<vector>
#include<queue>
#include<fstream>
#include<algorithm>
#include<limits.h>
#include<stack>
using namespace std;
#define ll long long
const long long mod = 1000000007;
ll n, d, m;
vector<ll> arr;
vector<ll> need;
bool ok(ll mid) {
ll done = 0; ll left = 0;
for (int i = 0; i < n; i++) {
done += min(mid, arr[i] + left);
if (mid < arr[i]) left += arr[i] - mid;
done -= need[i];
//cout << i << ' ' << done << '\n';
if (done < 0) {
return false;
}
}
return true;
}
int main() {
cin >> n >> d >> m;
arr.resize(n); need.resize(n);
for (int i = 0; i < m; i++) {
int x; cin >> x; x--;
arr[x]++;
need[x + d]++;
}
ll l = 0; ll r = 1e18;
ll ans = 0;
while (l <= r) {
ll mid = (l + r) / 2;
if (ok(mid)) {
ans = mid;
r = mid - 1;
}
else l = mid + 1;
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |