제출 #453180

#제출 시각아이디문제언어결과실행 시간메모리
453180BT21tataJob Scheduling (CEOI12_jobs)C++17
100 / 100
335 ms20788 KiB
#include<bits/stdc++.h>
// #pragma GCC target ("avx,avx2,fma")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef long double ld;
#define SPEED ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0)
#define rall(v) (v).rbegin(),(v).rend()
#define all(v) (v).begin(),(v).end()
#define OK cerr<<"OK"<<endl<<flush
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define F first
#define S second
#define y0 jahdakdh
#define y1 jahsadakdakdh
#define endl '\n'
using namespace std;
const ll MOD=1e9+7;
//mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());

ll n, d, m;
pll a[1000005];

bool check(ll x)
{
    int day=1, wtdy=0, pos=0;
    while(pos<m and day<=n)
    {
        if(a[pos].F<=day and day<=a[pos].F+d) wtdy++, pos++;
        else day++, wtdy=0;
        if(wtdy>=x) day++, wtdy=0;
    }
    if(pos==m) return 1;
    return 0;
}

int main()
{
    SPEED;
    cin>>n>>d>>m;
    for(int i=0; i<m; i++)
    {
        cin>>a[i].F;
        a[i].S=i+1;
    }
    sort(a, a+m);
    ll l=1, r=m, mid, pos=0;
    while(l<=r)
    {
        mid=(l+r)>>1;
        if(check(mid)) r=mid-1;
        else l=mid+1;
    }
    cout<<l<<endl;
    for(int i=0; i<n; i++, cout<<0<<endl)
        for(int j=0; j<l and pos<m; j++)
            cout<<a[pos++].S<<' ';

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...