# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
900208 | VMaksimoski008 | Job Scheduling (CEOI12_jobs) | C++14 | 125 ms | 4360 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using pii = pair<int, int>;
int N, D, M;
vector<int> v, cnt;
bool check(int mid) {
int left = mid;
queue<pii> q;
for(int i=1; i<=N; i++) {
left = mid;
if(cnt[i]) q.push({ i, cnt[i] });
while(left > 0 && !q.empty()) {
if(i - q.front().first > D) return false;
q.front().second--;
if(q.front().second == 0) q.pop();
left--;
}
}
return true;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> N >> D >> M;
v.resize(M);
cnt.resize(N+1);
for(int &x : v) cin >> x, cnt[x]++;
sort(all(v));
int l=1, r=M;
int ans = 0;
while(l <= r) {
int mid = (l + r) / 2;
if(check(mid)) ans = mid, r = mid - 1;
else l = mid + 1;
}
cout << ans << '\n';
for(int i=1; i<=N; i++) cout << 0 << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |