Submission #1108968

# Submission time Handle Problem Language Result Execution time Memory
1108968 2024-11-05T18:12:11 Z yazansh Job Scheduling (CEOI12_jobs) C++17
0 / 100
142 ms 21576 KB
/*************
  the author:     
  shimutski_zoro   
************ */
#include <bits/stdc++.h>
using namespace std;
#define yon(x) cout<<((x)?"YES":"NO");
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ff first 
#define ss second
#define em emplace_back
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define per(i,j,k) for(int i=k;i>=j;i--)
#define forp(x,y,a) for(auto &[x,y]:(a))
typedef long long  ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;
typedef vector<vl> vvl;
typedef vector<vpl> vvpl;
typedef vector<string> vs;
typedef deque<ll> dl;
const int mod=1e9+7;
ll inf =1e18+1;
const int M=1e6;
const int N=1e3+1; 
const ll dx[]={1,0,-1,0},dy[]={0,1,0,-1};
void solve(){
ll n,m,d;
cin>>n>>d>>m;
vl a(m);
rep(i,0,m-1)cin>>a[i];
vl idx(m);
iota(all(idx),0LL);
sort(all(idx),[&](ll i ,ll j){return a[i]<a[j];});
sort(all(a));

vvl tmp(n+1);
 function<bool(ll)>check=[&](ll r)->bool{
  tmp=vvl (n+1);
ll cnt=0;
rep(i,1,n){
  rep(j,1,r){
    if(a[cnt]>i)
    break;
if(a[cnt]+d>=i){
//cout<<cnt<<" "<<a[cnt]<<" "<<idx[cnt]<<" "<<i<<endl;
  tmp[i-1].em(idx[cnt++]+1);
}else return 0;
if(cnt==m)return 1;
  }

}
return 0;

 };
 // 1 1 2 2 2 3 3 4 4 5 6 6
 //0 4 1 3 8 
 vvl v(n+1);
 ll lo=2,hi=2;
 ll ans=m;
 while(lo<=hi){
  ll mid= lo + (hi-lo)/2;
if(check(mid)){
  hi=mid-1;
  ans=mid;
  v=tmp;
}else{
  lo=mid+1;
}
 }
cout<<ans<<endl;
//vvl v(n+1);
rep(i,0,n-1){
  for(auto it:v[i]){
    cout<<it<<" ";
  }
  cout<<0<<"\n";
}
}


signed main()
{
 
    ios_base::sync_with_stdio(NULL);
    cin.tie(nullptr);
    cout.tie(nullptr);
    #ifdef Usaco
    string f="herding";
    freopen((f+".in").c_str(),"r",stdin);
    freopen((f+".out").c_str(),"w",stdout);
    #endif
   int t = 1;
//cin >> t;
    while (t--)
    {
      solve();
    //  if(t>0)
      //cout<<endl;
    }
}
/*
*/
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 2640 KB Output isn't correct
2 Incorrect 9 ms 2596 KB Output isn't correct
3 Incorrect 8 ms 2640 KB Output isn't correct
4 Incorrect 9 ms 2640 KB Output isn't correct
5 Incorrect 8 ms 2640 KB Output isn't correct
6 Incorrect 9 ms 2640 KB Output isn't correct
7 Incorrect 15 ms 2676 KB Output isn't correct
8 Incorrect 9 ms 2640 KB Output isn't correct
9 Incorrect 19 ms 8932 KB Output isn't correct
10 Incorrect 18 ms 9040 KB Output isn't correct
11 Incorrect 17 ms 1872 KB Output isn't correct
12 Incorrect 33 ms 3592 KB Output isn't correct
13 Incorrect 46 ms 5192 KB Output isn't correct
14 Incorrect 70 ms 7240 KB Output isn't correct
15 Incorrect 79 ms 8264 KB Output isn't correct
16 Incorrect 103 ms 10528 KB Output isn't correct
17 Incorrect 122 ms 12104 KB Output isn't correct
18 Incorrect 139 ms 13632 KB Output isn't correct
19 Incorrect 142 ms 21576 KB Output isn't correct
20 Incorrect 122 ms 12104 KB Output isn't correct