# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1088533 | vjudge1 | Job Scheduling (CEOI12_jobs) | C++17 | 113 ms | 23376 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;
using pii = pair<int,int>;
const int maxn = 1e5 + 10;
int n,d,m;
vector<int> v[maxn],resp[maxn];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> n >> d >> m;
for(int i = 1;i <= m;i++){
int x;
cin >> x;
v[x].push_back(i);
}
int l = 1,r = m;
while(l <= r){
int mid = (l + r) >> 1;
bool check = 1;
int pos_dia = 1,qtd = 0;
for(int i = 1;i <= n && check;i++){
int val = (int) v[i].size();
if(pos_dia < i){
pos_dia = i;
qtd = 0;
}
while(val){
if(pos_dia - i > d){
check = 0;
break;
}
val--;
qtd++;
if(qtd == mid){
qtd = 0;
pos_dia++;
}
}
}
if(check) r = mid - 1;
else l = mid + 1;
}
cout << l << "\n";
int pos_dia = 1,qtd = 0;
for(int i = 1;i <= n;i++){
if(pos_dia < i){
pos_dia = i;
qtd = 0;
}
while(v[i].size()){
qtd++;
resp[pos_dia].push_back(v[i].back());
v[i].pop_back();
if(qtd == l){
qtd = 0;
pos_dia++;
}
}
}
for(int i = 1;i <= n;i++){
for(int j : resp[i])
cout << j << " ";
cout << 0 << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |