# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1088827 | akamizane | Job Scheduling (CEOI12_jobs) | C++17 | 0 ms | 0 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;
#ifndef ONLINE_JUDGE
#include<debug.h>
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
using ll = long long;
using pii = pair<int,int>;
#define int long long
#define el cout << '\n'
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FOD(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
template <class T1, class T2>void chmax(T1 &a, T2 b){a = max(a, b);}
template <class T1, class T2>void chmin(T1 &a, T2 b){a = min(a, b);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 2e5 + 5;
const ll mod = 998244353;
void solve(){
int n, d, m;
cin >> n >> d >> m;
vector<pii> x(m);
REP(i, m){
cin >> x[i].fi;
x[i].se = i + 1;
}
sort(all(x));
debug(x);
vector<vector<int>> ans;
auto check = [&] (int mid){
int cur = 1;
for (int i = 0; i < m; i += mid){
if (cur > x[i].fi + d) return false;
cur++;
}
return true;
};
int l = 0, r = m;
while(r - l > 1){
int m = (l + r) / 2;
if (check(m)) r = m;
else l = m;
}
for (int i = 0; i < m; i += r){
vector<int> u;
for (int j = i; j < i + r && j < m; j++){
u.pb(x[j].se);
}
u.pb(0);
ans.pb(u);
}
for (int i = 0; i < d; i++) ans.pb({0});
cout << r << '\n';
for (auto u : ans){
for (auto v : u) cout << v << " ";
cout << '\n';
}
}
int32_t main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("debug.txt", "w", stderr);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tests = 1;
//cin >> tests;
for (int itest = 1; itest <= tests; itest++){
cerr << "- TEST " << itest << ": \n";
solve();
el;
}
return 0;
}