Submission #1100348

#TimeUsernameProblemLanguageResultExecution timeMemory
1100348prabandhJob Scheduling (CEOI12_jobs)C++17
0 / 100
124 ms15944 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define int long long void solve() { int n,d,m; cin>>n>>d>>m; vector<int> a(n,0); vector<pair<int,int>> jobs(m); for(int i=0;i<m;i++) { int x; cin>>x; a[x-1]++; jobs[i] = {x-1,i+1}; } sort(jobs.begin(),jobs.end()); auto f = [&](int x) { vector<int> b = vector<int>(a.begin(),a.end()); int i = 0; int day = 0; while(i<n) { if(i<=day-d-1) return false; int tot = x; while(i<n && tot-b[i]>=0) { tot = tot-b[i]; i++; } b[i] -= tot; day++; } return true; }; int l=1; int r=m; int ans = -1; while(l<=r) { int mid = (l+r)/2; if(f(mid)) { ans = mid; r = mid-1; } else l=mid+1; } cout<<ans<<endl; // int j = 0; // while(j<m) // { // int tot = ans; // while(j<m && tot>0) // { // cout<<jobs[j].second<<" "; // tot--; // j++; // } // cout<<0<<endl; // } return; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T; //cin>>T; T = 1; while(T--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...