# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
682025 | handlename | Job Scheduling (CEOI12_jobs) | C++17 | 4 ms | 2644 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 pb push_back
#define mp make_pair
#define float long double
const int MOD=1e9+7;
//const int MOD=998244353;
const int sqn=450;
const long double eps=1e-6;
int n,d,m;
vector<int> arr[100001];
void runtc(){
cin>>n>>d>>m;
for (int i=1;i<=m;i++){
int x;
cin>>x;
arr[x].pb(i);
}
int mini=0,maxi=1e6;
while (mini+1<maxi){
int mid=(mini+maxi)/2;
bool can=true;
queue<int> q;
for (int i=1;i<=n;i++){
for (auto j:arr[i]) q.push(i+d);
int num=mid;
while (!q.empty() && num>0){
q.pop();
num--;
}
if (!q.empty() && q.front()<=i) can=false;
}
if (can) maxi=mid;
else mini=mid;
}
cout<<maxi<<'\n';
queue<int> q;
for (int i=1;i<=n;i++){
for (auto j:arr[i]) q.push(j);
int num=maxi;
while (!q.empty() && num>0){
cout<<q.front()<<' ';
q.pop();
num--;
}
cout<<0<<'\n';
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen("moocast.in","r",stdin);
//freopen("moocast.out","w",stdout);
freopen("input1.in","r",stdin);
//freopen("output1.out","w",stdout);
//freopen("perfectly_balanced_chapter_1_input.txt","r",stdin);
//freopen("hackercup_output.txt","w",stdout);
int tc;
//cin>>tc;
tc=1;
for (int i=1;i<=tc;i++){
//cout<<"Case #"<<i<<": ";
runtc();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |