제출 #1368560

#제출 시각아이디문제언어결과실행 시간메모리
1368560cadusantanabrJob Scheduling (CEOI12_jobs)C++20
80 / 100
1096 ms35024 KiB
#include<bits/stdc++.h>
using namespace std;
#define dbg(x) cerr << #x << " = " << x << endl;
#define fall(r,a,b) for(int r = a;r <= b;r++)
#define rfall(r,a,b) for(int r = a;r >= b;r--)
#define all(x) x.begin(), x.end()
#define int long long 
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define get(x,t) get<x>(t)
typedef pair<int,int> pii;
typedef tuple<int,int,int> tii;
typedef tuple<int,int,int,int> tii1;
const int maxn = 2e5+10;
const int mod = 1e9+7;
const int inf = 1e17;

vector<pii> v;

bool ok(int n,int d,int m){
    vector<pii> aux = v;

    fall(r,1,n){
        int mn = min(m,(int)aux.size());

        fall(i,1,mn){
            int ba = (int)aux.back().ff;
            if(ba<=r and r<=ba+d) aux.pop_back();
            else if(ba<=r and r>ba+d) return 0;
        }
    }

    if(aux.empty()) return 1;
    else return 0;
}    

void bb(int n,int d){
    int i = 1;
    int f = v.size();

    while(i<=f){
        int m = (i+f)/2;

        if(ok(n,d,m)) f = m-1;
        else i = m+1;
    }

    cout << i << endl;
    fall(r,1,n){
        int mn = min(i,(int)v.size());

        fall(j,1,mn){
            int ba = (int)v.back().ss;
            cout << ba << " ";
            v.pop_back();
        }
        cout << 0 << endl;
    }
}

int32_t main() {
    //freopen("socdist.in", "r", stdin);
    //freopen("socdist.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    int N,n,m,q,k;
    int a,b,c,d;
    int x,y;

    cin >> n >> d >> m;
    fall(r,1,m){ 
        cin >> a;
        v.pb({a,r});
    }
    sort(all(v));
    reverse(all(v));

    bb(n,d);
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…