# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
673003 | sudheerays123 | Job Scheduling (CEOI12_jobs) | C++17 | 250 ms | 22376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 = 1e6+5 , INF = 1e18 , MOD = 1e9+7;
vector<pair<ll,ll>> a(N);
void solve(){
ll n,d,m;
cin >> n >> d >> m;
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 = ceil((double)m/(double)n) , high = m;
ll ans;
while(low <= high){
ll mid = (low+high)/2;
bool possible = true;
for(ll i = 1; i <= m; i++){
ll day = ceil((double)i/(double)mid);
if(day > a[i].first+d) possible = false;
}
if(possible){
ans = mid;
high = mid-1;
}
else low = mid+1;
}
cout << ans << "\n";
ll p = 1;
for(ll i = 1; i <= n; i++){
ll left = ans;
while(left > 0 && p <= m){
cout << a[p].second << " ";
p++;
left--;
}
cout << "0\n";
}
}
int main(){
fast;
ll tc = 1;
// cin >> tc;
while(tc--) solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |