답안 #854392

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854392 2023-09-27T09:15:20 Z anhphant Job Scheduling (CEOI12_jobs) C++14
15 / 100
28 ms 2652 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;
    }
    
    //for(int i = 1; i <= M; ++i) cerr << A[i].first << "," << A[i].second << " "; cerr << endl;
    
    sort(A + 1, A + 1 + M);
    
    //for(int i = 1; i <= M; ++i) cerr << A[i].first << "," << A[i].second << " "; cerr << endl;
}

bool check(ll MachinesCnt) {
    //cerr << "MachinesCnt = " << MachinesCnt << endl;
    int idx = 1;
    
    for(int day = 1; day <= N; ++day) {
        //cerr << "Day " << day << " : " << endl;
        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;
            
            //cerr << "job " << idx << " is going to work with time at " << A[idx] << endl;
            
            used_machines_in_day++;
            idx++;
        }
        
        //cerr << "used_machines_in_day : " << used_machines_in_day << endl;
        //cerr << "used_machines_all_times : " << idx - 1 << endl;
        //cerr << endl;
    }
    
    return idx > M;
}

void construct(ll MachinesCnt) {
    //for(int i = 1; i <= M; ++i) cerr << A[i].first << "," << A[i].second << " "; cerr << endl;
    
    int idx = 1;
    
    for(int day = 1; day <= N; ++day) {
        //cerr << "Day " << day << " : " << endl;
        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;
            
            //cerr << "job " << idx << " is going to work with time at " << A[idx] << endl;
            
            cout << A[idx].second << " ";
            used_machines_in_day++;
            idx++;
        }
        
        cout << 0 << endl;    
        //cerr << "used_machines_in_day : " << used_machines_in_day << endl;
        //cerr << "used_machines_all_times : " << idx - 1 << endl;
        //cerr << endl;
    }
}

void process() {
    ll l = 1, r = N;
    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 Incorrect 9 ms 2140 KB Output isn't correct
2 Incorrect 9 ms 2140 KB Output isn't correct
3 Incorrect 9 ms 2140 KB Output isn't correct
4 Incorrect 9 ms 2140 KB Output isn't correct
5 Incorrect 9 ms 2140 KB Output isn't correct
6 Incorrect 9 ms 2020 KB Output isn't correct
7 Incorrect 9 ms 2140 KB Output isn't correct
8 Incorrect 9 ms 2140 KB Output isn't correct
9 Correct 28 ms 2652 KB Output is correct
10 Correct 28 ms 2652 KB Output is correct
11 Correct 20 ms 2392 KB Output is correct
12 Incorrect 5 ms 1884 KB Output isn't correct
13 Incorrect 5 ms 1884 KB Output isn't correct
14 Incorrect 9 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 1884 KB Output isn't correct
18 Incorrect 7 ms 1884 KB Output isn't correct
19 Incorrect 12 ms 2140 KB Output isn't correct
20 Incorrect 8 ms 1884 KB Output isn't correct