Submission #1301912

#TimeUsernameProblemLanguageResultExecution timeMemory
1301912BzslayedJob Scheduling (CEOI12_jobs)C++20
90 / 100
252 ms32836 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define ll long long #define ull unsigned long long #define ld long double #define pll pair<ll, ll> #define pii pair<int, int> #define coutpair(p) cout << p.first << " " << p.second << "|" template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; const ll INF = 1e15; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, d, m; cin >> n >> d >> m; pll jb[m]; for (int i=0; i<m; i++) cin >> jb[i].first, jb[i].second = i+1; sort(jb, jb+m); ll lo = 1, hi = 1e9, ans = INF; deque<pll> dq; while (lo <= hi){ ll x = (lo+hi)/2; dq.clear(); for (int i=1; i<=n; i++) dq.push_back({i, x}); bool pos = true; for (int i=0; i<m; i++){ ll tar = jb[i].first+d; if (tar < dq.front().first || dq.empty()){ pos = false; break; } while (jb[i].first > dq.front().first) dq.pop_front(); dq.front().second--; if (dq.front().second == 0) dq.pop_front(); } if (pos) hi = x-1, ans = min(ans, x); else lo = x+1; } dq.clear(); for (int i=1; i<=n; i++) dq.push_back({i, ans}); vector<ll> v[n+1]; for (int i=0; i<m; i++){ auto [day, id] = jb[i]; while (day > dq.front().first) dq.pop_front(); v[dq.front().first].push_back(id); dq.front().second--; if (dq.front().second == 0) dq.pop_front(); } cout << ans << "\n"; for (int i=1; i<=n; i++){ if (v[i].empty()) cout << 0 << "\n"; else{ for (auto it : v[i]) cout << it << " "; cout << 0 << "\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...