답안 #854394

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854394 2023-09-27T09:35:38 Z anhphant Job Scheduling (CEOI12_jobs) C++14
55 / 100
30 ms 2656 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
 
ll N, D, M;
pair<ll, ll> A[100007];
 
void initialize() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> N >> D >> M;
    for(int i = 1; i <= M; ++i) {
        cin >> A[i].first;
        A[i].second = i;
    }
    
    sort(A + 1, A + 1 + M);
}
 
bool check(ll MachinesCnt) {
    int idx = 1;
    
    for(int day = 1; day <= N; ++day) {
        ll used_machines_in_day = 0;
        while(idx <= M && used_machines_in_day < MachinesCnt) {
            if (A[idx].first + D < day) return 0;
            if (day < A[idx].first) break;
            
            used_machines_in_day++;
            idx++;
        }
    }
    
    return idx > M;
}
 
void construct(ll MachinesCnt) {
    int idx = 1;
    
    for(int day = 1; day <= N; ++day) {
        ll used_machines_in_day = 0;
        while(idx <= M && used_machines_in_day < MachinesCnt) {
            if (day < A[idx].first || A[idx].first + D < day) break;
            
            cout << A[idx].second << " ";
            used_machines_in_day++;
            idx++;
        }
        
        cout << 0 << endl;    
    }
}
 
void process() {
    ll l = 1, r = M;
    while(l < r) {
        ll mid = (l + r) / 2;
        if (check(mid)) r = mid;
        else l = mid + 1;
    }
    
    cout << l << endl;
    construct(l);
}
 
int main() {
    initialize();
    process();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 2396 KB Output is correct
2 Correct 16 ms 2396 KB Output is correct
3 Correct 14 ms 2396 KB Output is correct
4 Correct 14 ms 2396 KB Output is correct
5 Correct 16 ms 2656 KB Output is correct
6 Correct 14 ms 2396 KB Output is correct
7 Correct 14 ms 2396 KB Output is correct
8 Correct 14 ms 2636 KB Output is correct
9 Correct 27 ms 2600 KB Output is correct
10 Correct 30 ms 2652 KB Output is correct
11 Correct 23 ms 2392 KB Output is correct
12 Incorrect 9 ms 1884 KB Output isn't correct
13 Incorrect 5 ms 1884 KB Output isn't correct
14 Incorrect 7 ms 1884 KB Output isn't correct
15 Incorrect 6 ms 1884 KB Output isn't correct
16 Incorrect 7 ms 1884 KB Output isn't correct
17 Incorrect 8 ms 1880 KB Output isn't correct
18 Incorrect 8 ms 1884 KB Output isn't correct
19 Incorrect 13 ms 2136 KB Output isn't correct
20 Incorrect 8 ms 1880 KB Output isn't correct