# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
78619 | ekrem | Job Scheduling (CEOI12_jobs) | C++98 | 1089 ms | 15080 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 st first
#define nd second
#define mp make_pair
#define pb push_back
#define orta ((bas+son)/2)
#define N 1000005
using namespace std;
typedef pair < int , int > ii;
int n, m, d, bas = 1, son;
ii a[N];
bool dene(int x){
queue < int > q;
int ind = 1;
for(int i = 1; i <= n; i++){
while(a[ind].st == i){
q.push(i);
ind++;
}
int say = 0;
for(int j = 1; j <= x; j++)
if(!q.empty()){
if(i - q.front() > d)
return 0;
else
q.pop();
}
}
if(!q.empty())
return 0;
return 1;
}
void bastir(int x){
queue < int > q;
int ind = 1;
for(int i = 1; i <= n; i++){
while(a[ind].st == i){
q.push(ind);
ind++;
}
int say = 0;
for(int j = 1; j <= x; j++)
if(!q.empty()){
cout << a[q.front()].nd << " ";
q.pop();
}
cout << 0 << endl;
}
}
int main() {
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
scanf("%d %d %d",&n ,&d ,&m);
son = m;
for(int i = 1; i <= m; i++){
scanf("%d",&a[i].st);
a[i].nd = i;
}
sort(a + 1, a + m + 1);
while(bas < son)
if(dene(orta))
son = orta;
else
bas = orta + 1;
cout << orta << endl;
bastir(orta);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |