# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
500154 | mhsi2005 | Job Scheduling (CEOI12_jobs) | C++17 | 1097 ms | 33092 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.
// In the name of God
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T> using indexed_set = tree<T, null_type, less<T>,
rb_tree_tag, tree_order_statistics_node_update>;
#define watch(x) cerr << "{" << (#x) << " = " << x << "}" << '\n';
#define watch2(x, y) cerr << "{" << (#x) << " = " << x << ", " << (#y) << " = " << y << "}" << '\n';
#define watch3(x, y, z) cerr << "{" << (#x) << " = " << x << ", " << (#y) << " = " << y << ", " << (#z) << " = " << z << "}" << '\n';
#define fast_io ios::sync_with_stdio(false); cin.tie(0), cout.tie(0);
const ll maxn = 1e6 + 10, INF = 1e9;
ll n, d, m;
pii a[maxn];
bool ok (ll x)
{
multiset<int> s;
for (int i = 0; i < x; i++)
s.insert(1);
for (int i = 0; i < m; i++) {
int f = *s.begin();
if (f - a[i].first > d)
return false;
s.insert(f+1);
s.erase(s.begin());
}
return true;
}
int main()
{
fast_io
cin >> n >> d >> m;
for (int i = 0; i < m; i++) {
cin >> a[i].first;
a[i].second = i+1;
}
sort(a, a + m);
ll l = 0, r = 1e6;
while (r > l + 1) {
ll mid = (r + l) / 2;
if (ok(mid)) r = mid;
else l = mid;
}
cout << r << '\n';
vector<int> ans[(int)1e5 + 10];
multiset<int> s;
for (int i = 1; i <= r; i++)
s.insert(1);
for (int i = 0; i < m; i++) {
int f = *s.begin();
s.insert(f+1);
ans[f].push_back(a[i].second);
s.erase(s.begin());
}
for (int i = 1; i <= n; i++) {
for (int x : ans[i]) {
cout << x << ' ';
}
cout << 0 << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |