Submission #535360

#TimeUsernameProblemLanguageResultExecution timeMemory
535360PyrodoxJob Scheduling (CEOI12_jobs)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; bool cmp(const vector<ll>& a, const vector<ll>& b) { return a[0] < b[0]; } int main() { ll n, d, m; //ios::sync_with_stdio(false); //cin.tie(nullptr); cin >> n >> d >> m; vector<vector<ll>> jobs(m); for (ll i = 1; i <= m; ++i) { ll a; cin >> a; jobs[i - 1] = {a, i}; } sort(jobs.begin(), jobs.end(), cmp); vector<vector<ll>> ans; ll l = 1, r = m; /*while (l < r) { ll mid = l + (r - l) / 2, start = 0; //cout << "testing mid: " << mid << "\n"; bool check = true; vector<vector<ll>> jobstmp(n); for (ll i = 0; i < n && check; ++i) { //cout << i << "\n"; for (ll j = 0; j < mid && start <= m - 1; ++j) { //cout << "bat\n"; if (jobs[start][0] <= i + 1 && i + 1 - jobs[start][0] <= d) { jobstmp[i].push_back(jobs[start][1]); ++start; //cout << "at\n"; } else if (i + 1 - jobs[start][0] > d) { check = false; break; } else { break; } } jobstmp[i].push_back(0); } /*for (auto val : jobstmp) { for (ll i : val) { cout << i << " "; } cout << "\n"; }*/ //cout << "start: " << start << " check: " << "\n"; if (check && start == m) { //cout << "r from " << r << " to r -> " << mid << "\n"; r = mid; ans = jobstmp; } else { //cout << "l from " << l << " to l -> " << mid << " + 1\n"; l = mid + 1; } }*/ cout << l << "\n"; for (auto i : ans) { for (ll j = 0; j < i.size() - 1; ++j) { cout << i[j] << " "; } cout << i[i.size() - 1] << "\n"; } }

Compilation message (stderr)

jobs.cpp:49:9: warning: "/*" within comment [-Wcomment]
   49 |         /*for (auto val : jobstmp) {
      |          
jobs.cpp: In function 'int main()':
jobs.cpp:56:13: error: 'check' was not declared in this scope
   56 |         if (check && start == m) {
      |             ^~~~~
jobs.cpp:56:22: error: 'start' was not declared in this scope
   56 |         if (check && start == m) {
      |                      ^~~~~
jobs.cpp:58:17: error: 'mid' was not declared in this scope
   58 |             r = mid;
      |                 ^~~
jobs.cpp:59:19: error: 'jobstmp' was not declared in this scope; did you mean 'jobs'?
   59 |             ans = jobstmp;
      |                   ^~~~~~~
      |                   jobs
jobs.cpp:63:17: error: 'mid' was not declared in this scope
   63 |             l = mid + 1;
      |                 ^~~
jobs.cpp: At global scope:
jobs.cpp:65:7: error: expected unqualified-id before '/' token
   65 |     }*/
      |       ^
jobs.cpp:67:5: error: expected unqualified-id before 'for'
   67 |     for (auto i : ans) {
      |     ^~~
jobs.cpp:73:1: error: expected declaration before '}' token
   73 | }
      | ^