Submission #672989

#TimeUsernameProblemLanguageResultExecution timeMemory
672989sudheerays123Job Scheduling (CEOI12_jobs)C++17
25 / 100
325 ms65536 KiB
#include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define ll long long int const ll N = 100+5 , INF = 1e18 , MOD = 1e9+7; void solve(){ ll n,d,m; cin >> n >> d >> m; vector<pair<ll,ll>> a(m+5); for(ll i = 1; i <= m; i++){ cin >> a[i].first; a[i].second = i; } sort(a.begin()+1,a.begin()+m+1); ll low = 1 , high = m; ll ans; vector<ll> way[n+5]; while(low <= high){ ll mid = (low+high)/2; vector<ll> cur[n+5]; bool possible = true; ll machine = mid , day = 1; for(ll i = 1; i <= m;){ if(machine){ if(day > n){ possible = false; break; } if(day > a[i].first+d){ possible = false; break; } cur[day].push_back(a[i].second); machine--; i++; } else{ machine = mid; day++; } } if(possible){ ans = mid; for(ll i = 1; i <= n; i++) way[i].clear(); for(ll i = 1; i <= n; i++) for(auto u : cur[i]) way[i].push_back(u); high = mid-1; } else low = mid+1; } cout << ans << "\n"; for(ll i = 1; i <= n; i++){ for(auto u : way[i]) cout << u << " "; cout << "0\n"; } } int main(){ fast; ll tc = 1; // cin >> tc; while(tc--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...