Submission #419338

# Submission time Handle Problem Language Result Execution time Memory
419338 2021-06-07T01:07:00 Z freshmintt Job Scheduling (CEOI12_jobs) C++14
0 / 100
99 ms 29764 KB
#include<bits/stdc++.h>
#define MAXN 200005 //change. SET A SPACIOUS MAXN WHEN TESTING SO YOU DONT MESS UP WITH GARBAGE VALS OR SHIT
using namespace std;
typedef pair<long long,long long> pi;
typedef long long ll;
typedef long double ld;
ll N, D, M;

#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
vector<ll> jobs;
vector<pi> jobs_save;
ll days[MAXN];
vector<ll> plan[MAXN];

bool make_plan(ll machs) {

  fill(days, days+MAXN, 0);

  for (int i=0; i < M; i++) {
    ll machID = i % machs;

    days[machID] = max(days[machID]+1, jobs_save[i].first); // ++ vs +1, obstructs with comparison.
    plan[days[machID]-1].push_back(jobs_save[i].second+1);
  }
  return true;
}

bool works(ll machs) {

  fill(days, days+MAXN, 0);

  for (int i=0; i < M; i++) {
    ll machID = i % machs;
    // cout << machID << " ";

    days[machID] = max(days[machID]+1, jobs[i]); // ++ vs +1, obstructs with comparison.
    if ((days[machID] - jobs[i]) > D){
      return false;
    }
  }
  return true;
}

int main() { 
  FIO;
  cin >> N >> D >> M;

  
  for (int i = 0; i < M; i ++) {
    ll a; cin >> a; jobs.push_back(a); jobs_save.push_back({a,i});
  }

  cout << "reading in input to jobs";
  return 0;

  sort(jobs.begin(), jobs.end());
  sort(jobs_save.begin(), jobs_save.end());

  ll a = 1; ll b = 1E9; ll mid;
  while (a != b) {
    mid = (a+b)/2;
    // cout << a << " and " << mid << " and " << b<< endl;

    if (works(mid)) {
      
      b = mid;
    }
    else {
      a = mid + 1;
    }
  }

  cout << a << endl;

  make_plan(a);
  for (ll i = 0; i < N; i++) {
    for (auto i : plan[i]) {
      cout << i << " ";
    }
    cout << "0" << endl;

  }
}   
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 8120 KB Expected integer, but "reading" found
2 Incorrect 13 ms 8088 KB Expected integer, but "reading" found
3 Incorrect 14 ms 8120 KB Expected integer, but "reading" found
4 Incorrect 13 ms 8120 KB Expected integer, but "reading" found
5 Incorrect 13 ms 8068 KB Expected integer, but "reading" found
6 Incorrect 15 ms 8084 KB Expected integer, but "reading" found
7 Incorrect 13 ms 8120 KB Expected integer, but "reading" found
8 Incorrect 13 ms 8088 KB Expected integer, but "reading" found
9 Incorrect 13 ms 8068 KB Expected integer, but "reading" found
10 Incorrect 13 ms 7992 KB Expected integer, but "reading" found
11 Incorrect 15 ms 8168 KB Expected integer, but "reading" found
12 Incorrect 29 ms 11128 KB Expected integer, but "reading" found
13 Incorrect 37 ms 16576 KB Expected integer, but "reading" found
14 Incorrect 48 ms 16840 KB Expected integer, but "reading" found
15 Incorrect 55 ms 18808 KB Expected integer, but "reading" found
16 Incorrect 74 ms 28440 KB Expected integer, but "reading" found
17 Incorrect 84 ms 28348 KB Expected integer, but "reading" found
18 Incorrect 94 ms 27848 KB Expected integer, but "reading" found
19 Incorrect 99 ms 29764 KB Expected integer, but "reading" found
20 Incorrect 84 ms 28348 KB Expected integer, but "reading" found