Submission #565296

#TimeUsernameProblemLanguageResultExecution timeMemory
565296PranjalChandraJob Scheduling (CEOI12_jobs)C++14
0 / 100
1096 ms19496 KiB
#include <bits/stdc++.h> #include <limits.h> #define ll long long #define ull unsigned long long #define INF 1000000007 using namespace std; ll days, D, tasks; vector<pair<ll, ll>> schdl; vector<vector<ll>> ans; void ansPrint(ll mchnPoss) { ll day = 1; for (ll i = 1; i <= tasks; i = i + mchnPoss, ++day) { vector<ll> tmp; for (ll j = i; j < i + mchnPoss; j++) { tmp.push_back(schdl[j].second); ll slot = schdl[j].first + abs(schdl[j].first - day); } tmp.push_back(0); ans.push_back(tmp); } } bool ok(ll mchnPoss) { ll day = 1; for (ll i = 1; i <= tasks; i = i + mchnPoss, ++day) { for (ll j = i; j < i + mchnPoss; j++) { ll slot = schdl[j].first + abs(schdl[j].first - day); if (abs(slot - schdl[j].first) > D) return false; } } return true; } int main() { cin >> days >> D >> tasks; schdl.push_back({-1, -1}); for (ll i = 1; i <= tasks; i++) { ll x; cin >> x; schdl.push_back({x, i}); } sort(schdl.begin(), schdl.end()); ll l = 0; ll r = 1; while (ok(r) != true) r = r * 2; while (r > l + 1) { ll m = l + (r - l) / 2; if (ok(m)) r = m; else l = m; } ll machReq = r; ansPrint(machReq); cout << r << "\n"; for (auto v : ans) { for (auto e : v) cout << e << " "; cout << "\n"; } for (ll i = 0; i < days - ans.size(); ++i) cout << 0 << "\n"; return 0; }

Compilation message (stderr)

jobs.cpp: In function 'void ansPrint(long long int)':
jobs.cpp:21:16: warning: unused variable 'slot' [-Wunused-variable]
   21 |             ll slot = schdl[j].first + abs(schdl[j].first - day);
      |                ^~~~
jobs.cpp: In function 'int main()':
jobs.cpp:78:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   78 |     for (ll i = 0; i < days - ans.size(); ++i)
      |                    ~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...