Submission #853170

#TimeUsernameProblemLanguageResultExecution timeMemory
853170mall0809Job Scheduling (CEOI12_jobs)C++17
100 / 100
310 ms13868 KiB
#include <bits/stdc++.h> #define __gcd() gcd() #define C int(1e5+7) #define M int(1e9+7) #define el '\n' #define all(a) a.begin(),a.end() #define pb push_back using namespace std; typedef long long ll; int main(){ //ios_base::sync_with_stdio(false); //cin.tie(0);cout.tie(0); //freopen("","r",stdin); //freopen("","w",stdout); int n,d,m;cin>>n>>d>>m; vector<array<int,2>> a(m);for(int i=0;i<m;i++)cin>>a[i][0],a[i][1] = i; sort(all(a)); int l=1,r=1e7; auto check = [&](int mid){ int id = 0,cnt=mid; for(int i=1;i<=n && id < m;i++){ if(i > a[id][0] + d)return false; while(id < m && a[id][0] <= i && cnt>=1)cnt--,id++; cnt = mid; } return true; }; while(l<r){ int mid=(l+r)/2; if(check(mid))r=mid; else l=mid+1; } cout<<r<<el; int cnt = r; for(int i=1,id=0;i<=n;i++){ while(id < m && a[id][0] <= i && cnt >= 1){ cout<<a[id][1]+1<<' '; cnt--,id++; } cnt = r; cout<<0<<el; } }
#Verdict Execution timeMemoryGrader output
Fetching results...