Submission #157782

# Submission time Handle Problem Language Result Execution time Memory
157782 2019-10-12T22:18:21 Z InfiniteJest Job Scheduling (CEOI12_jobs) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

ifstream in("input.txt");
ofstream out("output.txt");

typedef long long ll;

int n,dk,m;
pair<int,int> v[1000001];

bool funz(int k){
  int p=1;
  for(int i=0;i<m;i+=k){
    //cout<<"p "<<p<<" i "<<i<<endl;
    for(int y=i;y<i+k&&y<m;y++){
      //cout<<"p "<<p<<" v "<<v[y].fi<<endl;
      p=max(p,v[y].fi);
      if(p>v[y].fi+dk)return 0;
    }
    p++;
  }
  return 1;
}

int main(){
  in>>n>>dk>>m;
  for(int i=0;i<m;i++){
    in>>v[i].fi;
    v[i].se=i;
  }
  sort(v,v+m);

  int s=1;
  int d=m;
  int minn=1e9;

  while(s<=d){
    int k=(s+d)/2;
    if(funz(k)){
      minn=min(minn,k);
      //cout<<"k "<<k<<endl;
      d=k-1;
    }
    else{
      s=k+1;
    }
  }
  cout<<minn<<endl;

  for(int i=0;i<m;i+=minn){
    for(int y=i;y<i+minn&&y<m;y++){
      cout<<v[y].se+1<<" ";
    }
    cout<<0<<endl;
  }
  for(int i=m/minn+min(1,m%minn);i<n;i++){
    cout<<0<<endl;
  }


}

  for(int i=f+1;i<=n;i++){
    cout<<0<<endl;
  }


}

Compilation message

jobs.cpp:73:3: error: expected unqualified-id before 'for'
   for(int i=f+1;i<=n;i++){
   ^~~
jobs.cpp:73:17: error: 'i' does not name a type
   for(int i=f+1;i<=n;i++){
                 ^
jobs.cpp:73:22: error: 'i' does not name a type
   for(int i=f+1;i<=n;i++){
                      ^
jobs.cpp:78:1: error: expected declaration before '}' token
 }
 ^