# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
635612 | nayhz | Job Scheduling (CEOI12_jobs) | C++17 | 436 ms | 38252 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.
// CEOI 2012 Dau 1 Job Scheduling
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define lck cout << "ick bmi 32.9\n"
#define cam_cs cout << "ick orz\n"
#define orz(x) cout << (x) << " orz\n"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define ll long long
#define ull unsigned long long
#define ld long double
// #define int long long
#define vi vector<int>
#define vll vector<long long>
#define vd vector<double>
#define vpii vector<pair<int, int>>
#define vpll vector<pair<long long, long long>>
#define vc vector<char>
#define vsc vector<string>
#define vb vector<bool>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define yes() cout << "YES\n"
#define no() cout << "NO\n"
#define impossible() cout << "Impossible\n"
using namespace std;
/*
>>>>>>>>>>>>>>>>>>>>>>>>>>END OF TEMPLATE HEADER<<<<<<<<<<<<<<<<<<<<<<<<
*/
void solve () {
int n, d, m; cin >> n >> d >> m;
vpii a(m);
for (int i = 0; i < m; i++) {cin >> a[i].fi; a[i].se = i + 1;}
sort(all(a));
vector<vi> ans(n);
int l = 1, r = m, mid;
function<pair<bool, vector<vi>> ()> check = [&] () {
vector<vi> ret(n);
int cnt = 0;
for (int day = 1; day <= n; day++) {
for (int i = 0; i < mid; i++) {
if (a[cnt].fi > day) break;
if (a[cnt].fi + d >= day){
ret[day - 1].pb(a[cnt++].se);
}
else return mp(false, ret);
if (cnt == m) {
return mp(true, ret);
}
}
}
return mp(false, ret);
};
pair<bool, vector<vi>> ret;
while (l < r) {
mid = l + ((r - l) >> 1);
ret = check();
if (ret.fi) {
r = mid, ans = ret.se;
} else l = mid + 1;
}
cout << l << '\n';
for (int i = 0; i < n; i++) {
for (auto &x : ans[i]) cout << x << ' ';
cout << "0\n";
}
}
signed main () {
cin.tie()->sync_with_stdio(false);
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |