답안 #900207

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
900207 2024-01-07T21:30:56 Z VMaksimoski008 Job Scheduling (CEOI12_jobs) C++14
100 / 100
240 ms 4336 KB
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;

int N, D, M;
vector<int> v, cnt;

bool check(int mid) {
    int left = mid;
    queue<int> q;

    for(int i=1; i<=N; i++) {
        left = mid;

        for(int j=0; j<cnt[i]; j++) q.push(i);

        while(left > 0 && !q.empty()) {
            int u = q.front();
            q.pop();
            if(i - u > D) return false;
            left--;
        }
    }

    return true;
}

int32_t main() {
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1272 KB Output is correct
2 Correct 20 ms 1292 KB Output is correct
3 Correct 20 ms 1272 KB Output is correct
4 Correct 20 ms 1272 KB Output is correct
5 Correct 21 ms 1344 KB Output is correct
6 Correct 20 ms 1292 KB Output is correct
7 Correct 23 ms 1268 KB Output is correct
8 Correct 20 ms 1292 KB Output is correct
9 Correct 29 ms 1368 KB Output is correct
10 Correct 32 ms 1372 KB Output is correct
11 Correct 23 ms 600 KB Output is correct
12 Correct 46 ms 1228 KB Output is correct
13 Correct 69 ms 1368 KB Output is correct
14 Correct 121 ms 2128 KB Output is correct
15 Correct 113 ms 2392 KB Output is correct
16 Correct 177 ms 2652 KB Output is correct
17 Correct 194 ms 3204 KB Output is correct
18 Correct 184 ms 3420 KB Output is correct
19 Correct 240 ms 4336 KB Output is correct
20 Correct 188 ms 3224 KB Output is correct