Submission #455179

# Submission time Handle Problem Language Result Execution time Memory
455179 2021-08-05T16:12:58 Z inluminas Job Scheduling (CEOI12_jobs) C++14
0 / 100
296 ms 65536 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=1e6+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 Runtime error 59 ms 52848 KB Memory limit exceeded
2 Runtime error 67 ms 52844 KB Memory limit exceeded
3 Runtime error 62 ms 52744 KB Memory limit exceeded
4 Runtime error 69 ms 52804 KB Memory limit exceeded
5 Runtime error 77 ms 52848 KB Memory limit exceeded
6 Runtime error 68 ms 52804 KB Memory limit exceeded
7 Runtime error 57 ms 52840 KB Memory limit exceeded
8 Runtime error 58 ms 52816 KB Memory limit exceeded
9 Runtime error 69 ms 53088 KB Memory limit exceeded
10 Runtime error 77 ms 53000 KB Memory limit exceeded
11 Runtime error 64 ms 52856 KB Memory limit exceeded
12 Runtime error 97 ms 54488 KB Memory limit exceeded
13 Runtime error 112 ms 57376 KB Memory limit exceeded
14 Runtime error 155 ms 59280 KB Memory limit exceeded
15 Runtime error 164 ms 59392 KB Memory limit exceeded
16 Runtime error 208 ms 61564 KB Memory limit exceeded
17 Runtime error 244 ms 65536 KB Memory limit exceeded
18 Runtime error 259 ms 65304 KB Memory limit exceeded
19 Runtime error 296 ms 65536 KB Memory limit exceeded
20 Runtime error 255 ms 65536 KB Memory limit exceeded