제출 #1303746

#제출 시각아이디문제언어결과실행 시간메모리
1303746rayxuJob Scheduling (CEOI12_jobs)C++20
35 / 100
171 ms20924 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("schedule.in","r",stdin);
    int n,d,m; cin>>n>>d>>m;
    vector<pair<int,int>> jobs(m);
    for (int i=0;i<m;i++) {
        cin>>jobs[i].first; jobs[i].first+=d;
        jobs[i].second = i+1;
    }
    sort(jobs.begin(),jobs.end());
    int lo=1,hi=m;
    auto test=[&](int x) {
        int curr=0,day=1;
        while (curr<m) {
            curr = min(m,curr+x);
            if (jobs[curr-1].first<day) return false;
            day++;
        }
        return (day-1)<=n;
    } ;
    while (lo<hi) {
        int mid=lo+(hi-lo)/2;
        if (test(mid)) hi = mid;
        else lo = mid+1;
    }
    cout<<lo<<"\n";
    int curr=0,last=0,day=1;
    while (curr<m) {
        curr = min(m,curr+lo);
        for (int i=last;i<curr;i++) cout<<jobs[i].second<<" ";
        cout<<0<<"\n";
        day++;
        last = curr;
    }
    for (int i=day;i<=n;i++) cout<<0<<"\n";
    return 0;
}
// if you get WA, go and read the question carefully again
// Then read the code for mixed variables, mistype, not considering a condition, etc.
#Verdict Execution timeMemoryGrader output
Fetching results...