Submission #1270341

#TimeUsernameProblemLanguageResultExecution timeMemory
1270341victorj0902Job Scheduling (CEOI12_jobs)C++20
0 / 100
228 ms23368 KiB
#include<bits/stdc++.h>
using namespace std;
struct job{
    int time;
    int idx;
    bool operator < (const job & other){
        return time < other.time;
    }
};
job a[1000010];
int n, m, d;
bool check(int k){
    int curtime = 1;
    for(int i = 1; i <= m; i+=k){
        if(a[i].time < curtime){
            return false;
        }
        curtime++;
    }
    return true;
}
vector<vector<int>> ans(100010, {0});
bool cmp(int a, int b){
    return a > b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> d >> m;
    for(int i = 1; i <= m; i++){
        cin >> a[i].time;
        a[i].time += d;
        a[i].idx = i;
    }
    sort(a+1, a+m+1);
    int l = 1, r = n;
    int mid;
    int num = n;
    while(l <= r){
        mid = (l+r)/2;
        if(check(mid) == true){
            num = mid;
            r = mid-1;
        }else{
            l = mid+1;
        }
    }
    cout << num << endl;
    for(int i = 1; i <= m; i++){
        ans[((i-1)/num)+1].push_back(a[i].idx);
    }
    for(int i = 1; i <= n; i++){
        sort(ans[i].begin(), ans[i].end(), cmp);
    }
    for(int i = 1; i <= n; i++){
        for(auto j : ans[i]){
            cout << j << " ";
        }
        cout << endl;
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...