Submission #1280048

#TimeUsernameProblemLanguageResultExecution timeMemory
1280048okok312Job Scheduling (CEOI12_jobs)C++20
100 / 100
104 ms14820 KiB
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef double db; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define vt vector #define fi first #define se second #define pb push_back #define mp make_pair #define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i) #define FORD(i, a, b) for(int i = (a), _b = (b); i >= _b; --i) #define REP(i, n) for(int i = 0; i < (n); ++i) #define sz(x) ((int)x.size()) #define all(a) (a).begin(), (a).end() #define el '\n' const ll N = 2e5 + 7; const ll MOD = 1e9 + 7; int n, d, m; int a[N]; vt<int> v[N], ans; bool f(int m){ deque<int> q; FOR(i, 1, n){ if(q.size() && q.front() < i - d) return 0; REP(j, a[i]) q.pb(i); REP(j, m){ if(q.empty()) break; q.pop_front(); } // cout << i << "----\n"; // REP(i, q.size()){ // cout << q[i] << " "; // } // cout << el; } return 1; } void solve(){ cin >> n >> d >> m; FOR(i, 1, m){ int x; cin >> x; a[x]++; v[x].pb(i); } int l = 1, r = 1e6; while(l < r){ int m = (l + r) >> 1; if(f(m)) r = m; else l = m + 1; } cout << l << el; FOR(i, 1, n){ for(auto x:v[i]){ ans.pb(x); } } int day = 1, k = 0; for(auto x:ans){ cout << x << ' '; k++; if(k == l){ k = 0; day++; cout << "0\n"; } } FOR(i, day, n){ cout << "0\n"; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("test.inp","r",stdin); freopen("test.out","w",stdout); freopen("test.err","w",stderr); #endif int ts=1; // cin>>ts; while(ts--){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...