Submission #591336

#TimeUsernameProblemLanguageResultExecution timeMemory
591336YassineBenYounesJob Scheduling (CEOI12_jobs)C++17
10 / 100
350 ms13888 KiB
/*
ID: Yassine BenYounes
TASK: maxcross
LANG: C++                 
*/
#include<bits/stdc++.h>
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD)
ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM)
ll modd(ll x, ll n){while(x < 0){x += n;}return (x % n);} // modulo for negative numbers
#define endl "\n"
#define ss second
#define ff first
#define all(x) (x).begin() , (x).end()
#define pb push_back
#define vi vector<int>
#define vii vector<pair<int,int>>
#define vl vector<ll>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd  pair<double,double>
#define vdd  vector<pdd>
#define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
const int mx = 2*1e5 + 9;
const ll mod = 1e9+7;
const ll inf = 1e15;
int n;int d;int m;

vii v;

bool f(int t){
    int day = 1;
    for(int i = 1; i <= m;i++){
        if(day - v[i].ff > t)return 0;
        if(i % t == 0)day++;
    }
    return 1;
}

int solve(){
    int low = 1;
    int high = 1e9 + 9;
    int ans = 0;
    while(low <= high){
        ll mid = low + (high - low) / 2;
        if(f(mid)){
            ans = mid;
            high = mid-1;
        }
        else{
            low = mid+1;
        }
    }
    return ans;
}

int main(){
    speed;
    cin >> n >> d >> m;
    v.pb({0, 0});
    for(int i = 0; i < m;i++){
        int x;cin >> x;
        v.pb({x, i+1});
    }
    sort(all(v));
    int x = solve();
    cout << x << endl;
    int c = 0;
    for(int i = 1; i <= m;i++){
        cout << v[i].ss << " ";
        if(i % x == 0){c++;cout << "0" << endl;}
    }
    for(int i = 0; i < n-c;i++){
        cout << "0" << endl;
    }
}
 
/*
    NEVER GIVE UP!
    DOING SMTHNG IS BETTER THAN DOING NTHNG!!!
*/
#Verdict Execution timeMemoryGrader output
Fetching results...