Submission #417503

# Submission time Handle Problem Language Result Execution time Memory
417503 2021-06-03T20:28:06 Z jackkkk Job Scheduling (CEOI12_jobs) C++11
Compilation error
0 ms 0 KB
using namespace std;
 
 
void quit() {
  cout.flush();
  exit(0);
}
long long n, d, m;
vector <pair<long long ,long long>> requests;
 
bool good(long long machines){
  for(long long i = 0; i < m; i++){
    if((i/machines+1)-requests[i].first>d){
      return false;
    }
  }
  return true;
}
 
 
 
int main(void){
  //freopen("qwer.in", "r", stdin);
  //freopen("qwer.out", "w", stdout);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n >> d >> m;
  requests.resize(m);
  for(long long i = 0; i < m; i++){
    cin >> requests[i].first;
    requests[i].second = i+1;
  }
  sort(requests.begin(), requests.end());
  
  long long s = 0, e = m;
  while(s!=e){
    long long mid = (s+e)/2;
    if(good(mid)){
      e=mid;
    }
    else{
      s=mid+1;
    }
  }
  cout << e << "\n";
  long long num_left = n;
  for(long long i = 0; i < m; i+=e){
    for(long long j = i; j < min(m, i+e); j++){
      cout << requests[j].second << " ";
    }
    num_left--;
    cout << "0\n";
  }
  for(long long i = 0; i < num_left; i++){
    cout << "0\n";
  }
  quit();
}

Compilation message

jobs.cpp: In function 'void quit()':
jobs.cpp:5:3: error: 'cout' was not declared in this scope
    5 |   cout.flush();
      |   ^~~~
jobs.cpp:1:1: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
  +++ |+#include <iostream>
    1 | using namespace std;
jobs.cpp:6:3: error: 'exit' was not declared in this scope
    6 |   exit(0);
      |   ^~~~
jobs.cpp: At global scope:
jobs.cpp:9:1: error: 'vector' does not name a type
    9 | vector <pair<long long ,long long>> requests;
      | ^~~~~~
jobs.cpp: In function 'bool good(long long int)':
jobs.cpp:13:23: error: 'requests' was not declared in this scope
   13 |     if((i/machines+1)-requests[i].first>d){
      |                       ^~~~~~~~
jobs.cpp: In function 'int main()':
jobs.cpp:25:3: error: 'ios' has not been declared
   25 |   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      |   ^~~
jobs.cpp:25:28: error: 'cin' was not declared in this scope
   25 |   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      |                            ^~~
jobs.cpp:25:28: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
jobs.cpp:25:40: error: 'cout' was not declared in this scope
   25 |   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      |                                        ^~~~
jobs.cpp:25:40: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
jobs.cpp:27:3: error: 'requests' was not declared in this scope
   27 |   requests.resize(m);
      |   ^~~~~~~~
jobs.cpp:32:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   32 |   sort(requests.begin(), requests.end());
      |   ^~~~
      |   short
jobs.cpp:47:30: error: 'min' was not declared in this scope; did you mean 'main'?
   47 |     for(long long j = i; j < min(m, i+e); j++){
      |                              ^~~
      |                              main