Submission #142924

#TimeUsernameProblemLanguageResultExecution timeMemory
142924jovan_bJob Scheduling (CEOI12_jobs)C++17
43 / 100
1087 ms18220 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; vector <int> vec[100005]; set <pair <int, int>> q; int n, d, m; vector <int> resenje[100005]; bool check(int k){ for(int i=1; i<=n; i++){ resenje[i].clear(); } for(int i=1; i<=n; i++){ for(auto c : vec[i]){ q.insert({i, c}); } if(q.empty()) continue; if(q.begin()->first < i-d) return 0; int g = k; while(!q.empty() && g--){ resenje[i].push_back(q.begin()->second); q.erase(q.begin()); } } return 1; } int main(){ ios_base::sync_with_stdio(false); cout.precision(10); cout<<fixed; cin >> n >> d >> m; for(int i=1; i<=m; i++){ int x; cin >> x; vec[x].push_back(i); } int l = 1, r = m, res = m; while(l <= r){ int mid = (l+r)/2; if(check(mid)){ res = mid; r = mid-1; } else l = mid+1; } check(res); cout << res << "\n"; for(int i=1; i<=n; i++){ for(auto c : resenje[i]) cout << c << " "; cout << "0\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...