답안 #1063580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1063580 2024-08-17T20:53:19 Z DeathIsAwe Job Scheduling (CEOI12_jobs) C++14
40 / 100
248 ms 20516 KB
#include <bits/stdc++.h>
using namespace std;


bool schedule(vector<int> requests, int n, int d, int m, int a) {
    bool ans = true;
    int counter;
    for (int i=0;i<n;i++) {
        counter = 0;
        while (counter < a && requests.size() > 0 && requests[requests.size() - 1] < i + 2) {
            counter++;
            if (requests[requests.size() - 1] > i + d + 1) {
                ans = false;
                break;
            }
            requests.pop_back();
        }
        if (!ans) {
            break;
        }
    }
    if (requests.size() > 0) {
        ans = false;
    }
    return ans;
}


int main() {
    int n, d, m; cin >> n >> d >> m;
    vector<int> requests(m);
    vector<vector<int>> requestmapper(n + 1);
    for (int i=0;i<m;i++) {
        cin >> requests[i];
        requestmapper[requests[i]].push_back(i + 1);
    }
    sort(requests.begin(), requests.end(), greater<int>());

    int top = 1000000, bottom = 0, middle;
    while (top > bottom + 1) {
        middle = (top + bottom) / 2;
        if (schedule(requests, n, d, m, middle)) {
            top = middle;
        } else {
            bottom = middle;
        }
    }



    int counter, temp;
    cout << top << '\n';
    for (int i=0;i<n;i++) {
        counter = 0;
        while (counter < top && requests.size() > 0 && requests[requests.size() - 1] < i + 2) {
            if (requests[requests.size() - 1] > i + d + 1) {
                break;
            }
            temp = requests[requests.size() - 1];
            counter++;
            cout << requestmapper[temp][requestmapper[temp].size() - 1] << ' ';
            requestmapper[temp].pop_back();
            requests.pop_back();
        }
        cout << 0 << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 2380 KB Output isn't correct
2 Incorrect 20 ms 2424 KB Output isn't correct
3 Incorrect 21 ms 2380 KB Output isn't correct
4 Incorrect 19 ms 2380 KB Output isn't correct
5 Incorrect 23 ms 2368 KB Output isn't correct
6 Incorrect 21 ms 2376 KB Output isn't correct
7 Incorrect 21 ms 2380 KB Output isn't correct
8 Incorrect 20 ms 2380 KB Output isn't correct
9 Incorrect 29 ms 4820 KB Output isn't correct
10 Incorrect 29 ms 4812 KB Output isn't correct
11 Correct 26 ms 2248 KB Output is correct
12 Correct 49 ms 4316 KB Output is correct
13 Correct 95 ms 6964 KB Output is correct
14 Correct 120 ms 9124 KB Output is correct
15 Correct 125 ms 10668 KB Output is correct
16 Correct 172 ms 13352 KB Output is correct
17 Correct 200 ms 16056 KB Output is correct
18 Incorrect 200 ms 16916 KB Output isn't correct
19 Incorrect 237 ms 20516 KB Output isn't correct
20 Correct 248 ms 16060 KB Output is correct