Submission #62687

#TimeUsernameProblemLanguageResultExecution timeMemory
62687eriksuenderhaufJob Scheduling (CEOI12_jobs)C++11
80 / 100
564 ms33792 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define enl printf("\n") #define ni(n) scanf("%d", &(n)) #define pri(n) printf("%d\n", (n)) #define pii pair<int, int> #define vi vector<int> #define pb push_back #define fi first #define se second using namespace std; const int INF = 1e9 + 7; const int MAXN = 1e6 + 50; pii a[MAXN]; vi ans[MAXN / 10]; int n, m, d, vis[MAXN]; bool ok(int mi) { int r = 1; for (int i = 1; i <= n; i++) { int tmp = min(m - r + 1, mi); for (int j = 0; j < mi && j + r <= m; j++) { if (a[j + r].fi + d < i) return false; if (a[j + r].fi > i) { tmp = j; break; } } r += tmp; } if (r < m) return false; return true; } int main() { ni(n), ni(d), ni(m); for (int i = 1; i <= m; i++) ni(a[i].fi), a[i].se = i; sort(a + 1, a + m + 1); int lo = 1, hi = m, ans2 = INF; while (lo <= hi) { int mi = (lo + hi) / 2; if (ok(mi)) hi = mi - 1, ans2 = min(mi, ans2); else lo = mi + 1; } int r = 1; for (int i = 1; i <= n; i++) { int tmp = min(m - r + 1, ans2); for (int j = 0; j < ans2 && j + r <= m; j++) { if (a[j + r].fi > i) { tmp = j; break; } ans[i].pb(a[j + r].se); } r += tmp; } pri(ans2); for (int i = 1; i <= n; i++, printf("0\n")) for (int j: ans[i]) { if (vis[j]) continue; vis[j] = 1; printf("%d ", j); } return 0; }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:43:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     ni(n), ni(d), ni(m);
                 ^
jobs.cpp:43:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
jobs.cpp:43:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
jobs.cpp:45:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         ni(a[i].fi), a[i].se = i;
                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...