# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
465151 | tphuc2908 | Job Scheduling (CEOI12_jobs) | C++14 | 391 ms | 13780 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 rep(i, x, y) for(int i = x; i <= y; ++i)
#define repi(i,x,y) for(int i = x; i >= y; --i)
#define ci(x) int x; cin>> x
#define TC(t) ci(t); while(t--)
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define cii(x, y) ci(x); ci(y)
typedef long long ll;
typedef vector<int> vi;
const int N = 1e6 + 5;
const int mod = 1e9+7;
const int inf = 1e9 + 5;
void readfile(){
#ifdef ONLINE_JUDGE
#else
freopen("text.inp", "r", stdin);
#endif // ONLINE_JUDGE
// freopen("angry.in", "r", stdin);
// freopen("angry.out", "w", stdout);
}
int n, d, m;
pair<int,int> a[N];
void inp(){
cin >> n >> d >> m;
rep(i,1,m){
cin >> a[i].fi;
a[i].se = i;
}
sort(a + 1, a + m + 1);
}
bool check(int x){
int j = 1;
queue<pair<int,int> > q;
rep(i,1,n){
while(j <= m && a[j].fi==i){
q.push(a[j]);
++j;
}
int cnt = 0;
while(cnt < x && !q.empty()){
if(i - q.front().fi > d)
return 0;
q.pop();
++cnt;
}
}
return q.empty();
}
void process(){
int l = 1, r = m, res;
while(l <= r){
ll mid = (l + r) >> 1;
if(check(mid)){
res = mid;
r = mid - 1;
}
else l = mid + 1;
}
cout << res << '\n';
queue<pair<int,int> > q;
int j = 1;
rep(i,1,n){
while(j <= m && a[j].fi==i){
q.push(a[j]);
++j;
}
int cnt = 0;
while(cnt < res && !q.empty()){
cout << q.front().se << ' ';
q.pop();
++cnt;
}
cout << 0 << '\n';
}
}
int main(){
// readfile();
ios_base::sync_with_stdio(0);
cin.tie(0);
inp();
process();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |