# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
853170 | mall0809 | Job Scheduling (CEOI12_jobs) | C++17 | 310 ms | 13868 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>
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |