Submission #455180

# Submission time Handle Problem Language Result Execution time Memory
455180 2021-08-05T16:13:40 Z inluminas Job Scheduling (CEOI12_jobs) C++17
100 / 100
258 ms 20560 KB
#include"bits/stdc++.h"
using namespace std;

#define ll long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false)

const int lmt=1e5+10;
vector<int>adj[lmt],res[lmt];
int n,d,m,cnt[lmt];

int main(){
  fastio;

  cin>>n>>d>>m;
  for(int i=1;i<=m;i++){
    int a;
    cin>>a;
    adj[a].push_back(i);
    cnt[a]++;
  }
  int lo=1,hi=m;
  while(lo<hi){
    int mid=(lo+hi)>>1,ache[lmt]={0},cur=1,bad=0;
    for(int i=1;i<=n;i++){
      for(int j=1;j<=cnt[i];j++){
        while(cur<i || ache[cur]==mid) cur++;
        if(cur-i>d){
          bad=1;
          break;
        }
        ache[cur]++;
      }
      if(bad) break;
    }
    if(bad) lo=mid+1;
    else hi=mid;
  }
  int ache[lmt]={0},cur=1;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=cnt[i];j++){
      while(cur<i || ache[cur]==lo) cur++;
      ache[cur]++;
      res[cur].push_back(adj[i][j-1]);
    }
  }
  cout<<lo<<endl;
  for(int i=1;i<=n;i++){
    for(int v:res[i]) cout<<v<<" ";
    cout<<0<<endl;
  }
}
# Verdict Execution time Memory Grader output
1 Correct 28 ms 7020 KB Output is correct
2 Correct 29 ms 6952 KB Output is correct
3 Correct 28 ms 6988 KB Output is correct
4 Correct 27 ms 7020 KB Output is correct
5 Correct 29 ms 7048 KB Output is correct
6 Correct 29 ms 6968 KB Output is correct
7 Correct 29 ms 7116 KB Output is correct
8 Correct 27 ms 6964 KB Output is correct
9 Correct 38 ms 7236 KB Output is correct
10 Correct 37 ms 7204 KB Output is correct
11 Correct 31 ms 6968 KB Output is correct
12 Correct 59 ms 8732 KB Output is correct
13 Correct 99 ms 11640 KB Output is correct
14 Correct 119 ms 13400 KB Output is correct
15 Correct 131 ms 13508 KB Output is correct
16 Correct 172 ms 15804 KB Output is correct
17 Correct 207 ms 20412 KB Output is correct
18 Correct 214 ms 19416 KB Output is correct
19 Correct 258 ms 20224 KB Output is correct
20 Correct 226 ms 20560 KB Output is correct