답안 #973187

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973187 2024-05-01T15:40:00 Z njoop Job Scheduling (CEOI12_jobs) C++17
20 / 100
186 ms 16932 KB
#include <bits/stdc++.h>

using namespace std;

int n, d, m, in, l=0, r=1e9, mid;
vector<int> t[100010];

bool solve(int num) {
    queue<int> q;
    for(int i=1; i<=n; i++) {
        for(int j: t[i]) q.push(i);
        for(int j=1; j<=num && q.size(); j++) q.pop();
        if(q.size() && i-q.front() > d) {
            return 0;
        }
    }
    return 1;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> d >> m;
    for(int i=1; i<=m; i++) {
        cin >> in;
        t[in].push_back(i);
    }
    while(l < r) {
        mid = (l+r)>>1;
        if(solve(mid)) {
            r = mid;
        } else {
            l = mid+1;
        }
    }
    cout << l << "\n";
    queue<int> q;
    for(int i=1; i<=n; i++) {
        for(int j: t[i]) q.push(j);
        for(int j=1; j<=l && q.size(); j++) {
            cout << q.front() << " ";
            q.pop();
        }
        cout << "0\n";
    }
    return 0;
}

Compilation message

jobs.cpp: In function 'bool solve(int)':
jobs.cpp:11:17: warning: unused variable 'j' [-Wunused-variable]
   11 |         for(int j: t[i]) q.push(i);
      |                 ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 4312 KB Output isn't correct
2 Incorrect 21 ms 4312 KB Output isn't correct
3 Incorrect 21 ms 4428 KB Output isn't correct
4 Incorrect 20 ms 4304 KB Output isn't correct
5 Incorrect 28 ms 4304 KB Output isn't correct
6 Incorrect 22 ms 4360 KB Output isn't correct
7 Incorrect 21 ms 4508 KB Output isn't correct
8 Incorrect 21 ms 4460 KB Output isn't correct
9 Incorrect 37 ms 4436 KB Output isn't correct
10 Incorrect 31 ms 4468 KB Output isn't correct
11 Correct 20 ms 4180 KB Output is correct
12 Correct 46 ms 6220 KB Output is correct
13 Incorrect 58 ms 7960 KB Output isn't correct
14 Correct 92 ms 10088 KB Output is correct
15 Incorrect 94 ms 11088 KB Output isn't correct
16 Correct 142 ms 13588 KB Output is correct
17 Incorrect 180 ms 16160 KB Output isn't correct
18 Incorrect 155 ms 15792 KB Output isn't correct
19 Incorrect 186 ms 16932 KB Output isn't correct
20 Incorrect 155 ms 16168 KB Output isn't correct