Submission #260065

#TimeUsernameProblemLanguageResultExecution timeMemory
260065MiricaMateiJob Scheduling (CEOI12_jobs)C++17
100 / 100
355 ms17272 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int MAXM = 1000005; pair<int, int> v[MAXM]; bool ok(int n, int d, int m, int k) { int j = 1; for (int i = 1; i <= n; ++i) { int k1 = k; while (j <= m && v[j].first <= i && k1 > 0) { if (i - v[j].first > d) return 0; j++; k1--; } } return 1; } int main() { //freopen("date.in", "r", stdin); //freopen("date.out", "w", stdout); int n, d, m; scanf("%d%d%d", &n, &d, &m); for (int i = 1; i <= m; ++i) { scanf("%d", &v[i].first); v[i].second = i; } sort(v + 1, v + m + 1); int ans = 0; for (int i = 19; i >= 0; --i) if (ans + (1 << i) < m && !ok(n, d, m, ans + (1 << i))) ans += (1 << i); printf("%d\n", ans + 1); int k = ans + 1, j = 1; for (int i = 1; i <= n; ++i) { int k1 = k; while (j <= m && v[j].first <= i && k1 > 0) { printf("%d ", v[j].second); if (i - v[j].first > d) return 0; j++; k1--; } printf("0\n"); } return 0; }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &n, &d, &m);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &v[i].first);
     ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...