답안 #1029510

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1029510 2024-07-21T00:49:13 Z ArthuroWich Job Scheduling (CEOI12_jobs) C++17
55 / 100
363 ms 21460 KB
#include <bits/stdc++.h>
using namespace std;
bool check(vector<int> a, int mi, int n, int d) {
    int i = 1;
    while(a.size() && i <= n) {
        for (int j = 0; j < mi; j++) {
            if (a.empty()) {
                break;
            }
            if (i > 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 30 ms 2516 KB Output isn't correct
2 Incorrect 23 ms 2512 KB Output isn't correct
3 Incorrect 23 ms 2520 KB Output isn't correct
4 Incorrect 25 ms 2768 KB Output isn't correct
5 Incorrect 23 ms 2520 KB Output isn't correct
6 Incorrect 23 ms 2648 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 117 ms 2680 KB Output is correct
10 Correct 116 ms 2764 KB Output is correct
11 Correct 25 ms 2520 KB Output is correct
12 Correct 44 ms 4880 KB Output is correct
13 Correct 71 ms 7620 KB Output is correct
14 Correct 113 ms 9924 KB Output is correct
15 Incorrect 123 ms 11456 KB Output isn't correct
16 Correct 160 ms 15104 KB Output is correct
17 Correct 198 ms 17368 KB Output is correct
18 Correct 204 ms 18872 KB Output is correct
19 Correct 363 ms 21460 KB Output is correct
20 Correct 195 ms 16312 KB Output is correct