# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
639945 | ghostwriter | Job Scheduling (CEOI12_jobs) | C++14 | 211 ms | 17012 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;
#ifdef LOCAL
#include <debug.h>
#endif
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
Tran The Bao
CTL - Da Lat
Cay ngay cay dem nhung deo duoc cong nhan
*/
const int N = 1e5 + 1;
const int M = 1e6 + 1;
int n, d, m, t[M];
vi a[N];
bool check(int x) {
deque<int> a1;
FOR(i, 1, n) {
EACH(j, a[i]) a1.pb(j);
int cnt = min(x, sz(a1));
FOR(j, 1, cnt) {
int cur = a1.front();
if (i > t[cur] + d) return 0;
a1._pf();
}
}
return a1.empty();
}
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
// freopen(file".inp", "r", stdin);
// freopen(file".out", "w", stdout);
cin >> n >> d >> m;
FOR(i, 1, m) {
cin >> t[i];
a[t[i]].pb(i);
}
int l = 1, r = m, ans = -1;
WHILE(l <= r) {
int mid = l + (r - l) / 2;
if (check(mid)) {
ans = mid;
r = mid - 1;
}
else l = mid + 1;
}
cout << ans << '\n';
deque<int> a1;
FOR(i, 1, n) {
EACH(j, a[i]) a1.pb(j);
int cnt = min(ans, sz(a1));
FOR(j, 1, cnt) {
int cur = a1.front();
cout << cur << ' ';
a1._pf();
}
cout << 0 << '\n';
}
return 0;
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |