Submission #831225

#TimeUsernameProblemLanguageResultExecution timeMemory
831225TimAniJob Scheduling (CEOI12_jobs)C++17
0 / 100
214 ms13772 KiB
#include <algorithm> #include <cassert> #include <cstdio> #include <iostream> #include <string> #include <vector> #include <set> #include <map> #include <numeric> #include <stack> #include <queue> #include <cmath> //#ifndef ONLINE_JUDGE //#include "/home/linux/Learning/headers/debug.h" //#else //#define debug(...) //#endif using namespace std; using ll = long long; void setIO(string File_name) { cin.tie(0)->sync_with_stdio(0); if (File_name.size()) { freopen((File_name + ".in").c_str(), "r", stdin); freopen((File_name + ".out").c_str(), "w", stdout); } } void sol() { int n, d, m; cin >> n >> d >> m; vector<pair<int, int>> v(m); for (int i = 0; i < m; i++) cin >> v[i].first, v[i].second = i + 1; sort(v.begin(), v.end()); auto good = [&](int mid) { for (int i = 0, day = 0, free = mid; i < m; day++, free = mid) { while (i < m && v[i].first <= day && free > 0) { if (day - v[i].first > d) return false; i++; free--; } } return true; }; int l = 0, r = m + 1; while (r > l) { int mid = l + (r - l) / 2; if (good(mid)) r = mid; else l = mid + 1; } cout << r << '\n'; int day = v[0].first; int free = r; for (int i = 0, j = 1; j <= n; j++) { while (i < m && v[i].first <= day && free > 0) { cout << v[i].second << ' '; i++; free--; } cout << "0 \n"; day++; free = r; } } int main() { setIO(""); int T = 1; //cin >> T; while (T--) sol(); return 0; }

Compilation message (stderr)

jobs.cpp: In function 'void setIO(std::string)':
jobs.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         freopen((File_name + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen((File_name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...