답안 #1029509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1029509 2024-07-21T00:47:53 Z ArthuroWich Job Scheduling (CEOI12_jobs) C++17
55 / 100
297 ms 20920 KB
#include <bits/stdc++.h>
using namespace std;
bool check(vector<int> a, int mi, int n, int d) {
    int i = 0;
    while(a.size() && i < n) {
        for (int j = 0; j < mi; j++) {
            if (a.empty()) {
                break;
            }
            if (i+1 > a.back()+d) {
                return 0;
            }
            a.pop_back();
        }
        i++;
    }
    return a.size() == 0;
}
void solve() {
    int n, d, m;
    cin >> n >> d >> m;
    vector<int> a(m);
    vector<pair<int, int>> ans;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        ans.push_back({a[i], i});
    }
    sort(a.rbegin(), a.rend());
    sort(ans.begin(), ans.end());
    int l = 1, r = n;
    while(l < r) {
        int mi = (l+r)/2;
        if (check(a, mi, n, d)) {
            r = mi;
        } else {
            l = mi+1;
        }
    }
    cout << l << endl;
    int j = 0;
    for (int i = 0; i < n; i++) {
        int c = l;
        while(j < m && c--) {
            cout << ans[j].second+1 << " ";
            j++;
        }
        cout << 0 << endl;
    }
}
int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    t = 1;
    while(t--) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 2516 KB Output isn't correct
2 Incorrect 24 ms 2516 KB Output isn't correct
3 Incorrect 24 ms 2520 KB Output isn't correct
4 Incorrect 24 ms 2520 KB Output isn't correct
5 Incorrect 24 ms 2520 KB Output isn't correct
6 Incorrect 24 ms 2516 KB Output isn't correct
7 Incorrect 24 ms 2520 KB Output isn't correct
8 Incorrect 23 ms 2516 KB Output isn't correct
9 Correct 113 ms 2712 KB Output is correct
10 Correct 124 ms 2640 KB Output is correct
11 Correct 24 ms 2512 KB Output is correct
12 Correct 47 ms 4808 KB Output is correct
13 Correct 87 ms 7372 KB Output is correct
14 Correct 113 ms 9396 KB Output is correct
15 Incorrect 121 ms 11576 KB Output isn't correct
16 Correct 166 ms 14524 KB Output is correct
17 Correct 214 ms 16836 KB Output is correct
18 Correct 220 ms 18668 KB Output is correct
19 Correct 297 ms 20920 KB Output is correct
20 Correct 200 ms 18068 KB Output is correct