# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1042671 | joelgun14 | Job Scheduling (CEOI12_jobs) | C++17 | 178 ms | 30264 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 <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl "\n"
#define ll long long
#define mp make_pair
#define ins insert
#define lb lower_bound
#define pb push_back
#define ub upper_bound
#define lll __int128
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int main() {
ios_base::sync_with_stdio(0); cin.tie(NULL);
int n, d, m;
cin >> n >> d >> m;
int a[m + 1];
for(int i = 1; i <= m; ++i)
cin >> a[i];
vector<int> cnt[n + 1];
memset(cnt, 0, sizeof(cnt));
for(int i = 1; i <= m; ++i)
cnt[a[i]].pb(i);
int l = 0, r = 1e6, ans = -1;
vector<int> proc[n + 1];
while(l <= r) {
int mid = (l + r) / 2;
queue<pair<int, int>> pend;
bool valid = 1;
vector<int> cur[n + 1];
for(int i = 1; i <= n; ++i) {
for(auto x : cnt[i])
pend.push(mp(x, i));
int sz = pend.size();
for(int j = 0; j < min(sz, mid); ++j)
valid &= pend.front().se >= i - d, cur[i].pb(pend.front().fi), pend.pop();
}
if(pend.empty() && valid) {
for(int i = 1; i <= n; ++i)
proc[i] = cur[i];
r = mid - 1, ans = mid;
}
else
l = mid + 1;
}
cout << ans << endl;
for(int i = 1; i <= n; ++i) {
for(auto j : proc[i])
cout << j << " ";
cout << 0 << endl;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |