Submission #528156

#TimeUsernameProblemLanguageResultExecution timeMemory
528156AanjaneyJob Scheduling (CEOI12_jobs)C++17
35 / 100
251 ms24132 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define MOD 1000000007 #define MODA 998244353 #define pb push_back #define sortv(v) sort(v.begin(), v.end()) #define sorta(A, N) sort(A, A + N) #define debug(x) cerr << #x << " is " << x; #define rep(i, a, N) for (ll i = a; i < N; i++) #define f first #define s second #define uniq(v) \ { \ sort(v.begin(), v.end()); \ v.erase(unique(v.begin(), v.end()), v.end()); \ } #define speed \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); using namespace std; void solve(ll tcase) { ll N, D, M; cin >> N >> D >> M; vector<pair<ll, ll> > a(M); rep(i, 0, M) { cin >> a[i].f; a[i].f += D; a[i].s = i; } sortv(a); ll lo = 1, hi = M + 1; while (lo < hi) { ll mid = (lo + hi) / 2; ll pos = 0, flag = 1; rep(day, 1, N + 1) { pos += mid; ll x = min(pos, M); ll last = a[x - 1].f; if (last < day) { flag = 0; break; } if (pos >= M) break; } if (!flag) lo = mid + 1; else hi = mid; } cout << hi << "\n"; ll pos = 0; rep(day, 1, N + 1) { while (pos < M) { ll x = min(pos + hi, M); rep(i, pos, x) cout << a[i].s + 1 << ' '; pos = x; break; } cout << "0\n"; } } int main() { speed; ll t = 1; rep(i, 1, t + 1) solve(i); }
#Verdict Execution timeMemoryGrader output
Fetching results...