# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
553845 | wyhong3103 | Job Scheduling (CEOI12_jobs) | C++14 | 246 ms | 13772 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>
#include <limits>
#define all(x) begin(x),end(x)
#define fir first
#define sec second
#define sz(x) x.size()
#define pb push_back
using namespace std;
using vi = vector<int>;
using pi = pair<int,int>;
using ll = long long;
const double EPS = (1e-7);
void setio(string s){
freopen((s + ".in").c_str(),"r",stdin);
freopen((s + ".out").c_str(),"w",stdout);
}
bool valid(vector<pi>& a, int n, int d){
int day = 1;
int cur = 0;
for(auto& i : a){
if ((day-i.fir) > d){
return false;
}
cur++;
if (cur == n){
cur = 0;
day++;
}
}
return true;
}
void solve(){
int n, d, m;
cin >> n >> d >> m;
vector<pi> a(m);
for(int i{}; i < m; i++){
cin >> a[i].fir;
a[i].sec = i+1;
}
sort(all(a));
int lo = 1, hi = m;
while (hi > lo){
int mid = lo + (hi-lo)/2;
if (valid(a, mid, d)){
hi = mid;
}else{
lo = mid+1;
}
}
cout << lo << '\n';
int p = 0;
for(int i{}; i < n; i++){
for(int i{}; i < lo; i++){
if (p < sz(a)){
cout << a[p].sec << ' ';
p++;
}else break;
}
cout << 0 << '\n';
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |