# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
415376 | HadiHosseini | Job Scheduling (CEOI12_jobs) | C++14 | 356 ms | 21324 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;
void show(long long cur, vector<pair<int, int>> v, int n, int d, int m) {
int j = 0;
for(int day = 1 ; day <= n ; day++){
long long rev = cur;
while(j < m && rev && v[j].first <= day){
if(v[j].first <= day + d){
cout << v[j].second << " ";
rev--;
j++;
}
}
cout << "0\n";
}
}
bool f(long long cur, vector<pair<int, int>> v, int n, int d, int m) {
int j = 0;
for(int day = 1 ; day <= n ; day++){
long long rev = cur;
while(j < m && rev && v[j].first <= day){
if(v[j].first <= day + d && v[j].first >= day - d){
rev--;
j++;
}
else {
return false;
}
}
}
if(j == m) return true;
return false;
}
long long bs(vector<pair<int, int>> v, int n, int d, int m){
long long lo = -1; long long hig = 1e5;
for(long long i = hig - lo; i; i /= 2){
while(lo + i <= hig && !f(lo + i, v, n, d, m)) lo += i;
}
return lo + 1;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n, d, m; cin >> n >> d >> m;
vector<pair<int, int>> v(m);
for(int i = 1 ; i <= m; i++){
cin >> v[i - 1].first;
v[i - 1].second = i;
}
sort(v.begin(), v.end());
long long ans = bs(v, n, d, m);
cout << ans << "\n";
show(ans, v, n, d, m);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |