제출 #540449

#제출 시각아이디문제언어결과실행 시간메모리
540449BhavayGoyalJob Scheduling (CEOI12_jobs)C++14
80 / 100
323 ms42352 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define int long long #define vii vector<vector<int>> #define vi vector<int> #define v vector #define pii pair<int, int> #define mii map<int, int> #define umii unordered_map<int, int> #define si set<int> #define usi unordered_set<int> #define all(x) x.begin(), x.end() #define f first #define s second #define endl "\n" #define pb push_back #define MOD 1000000007 int inf = 1e9; int n, d, m; v<pii> arr(m); vii answer; vii actualans; bool isFiss(int mid) { for (int i = 0; i < n; i++) answer[i].clear(); int idx = 0; for (int i = 1; i <= n; i++) { for (int j = 0; j < mid; j++) { if (arr[idx].f > i) break; if (i <= arr[idx].f + d) answer[i-1].pb(arr[idx++].s); else return false; if (idx == m) return true; } } return false; } void sol() { cin >> n >> d >> m; arr = v<pii>(m); answer = vii(n); for (int i = 0; i < m; i++) { cin >> arr[i].f; arr[i].s = i+1; } sort (all(arr)); int i = 1, j = m; int ans = m; while (i <= j) { int mid = (i+j)/2; if (isFiss(mid)) { actualans = answer; ans = mid; j = mid-1; } else i = mid+1; } cout << ans << endl; for (int i = 0; i < n; i++) { for (auto j : actualans[i]) cout << j << " "; cout << 0 << endl; } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t; t = 1; // cin >> t; for (int i = 1; i <= t; i++) sol(); }
#Verdict Execution timeMemoryGrader output
Fetching results...