# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
500158 | mhsi2005 | Job Scheduling (CEOI12_jobs) | C++17 | 1098 ms | 18760 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// 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;
int n, d, m;
pii a[maxn];
vector<vector<int>> ans(n);
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
bool ok (int x)
{
ans.clear();
ans.resize(n+10);
int pos = 0;
vector<int> machines(x);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= x; j++) {
if (a[pos].first > i) break;
if (machines[j] - a[pos].first <= d) {
machines[j] = max(machines[j], a[pos].first) + 1;
ans[machines[j]-1].push_back(a[pos].second);
pos++;
}
if (pos == m) return true;
}
}
return false;
}
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);
int l = 0, r = 1e6;
while (r > l + 1) {
int mid = (r + l) / 2;
if (ok(mid)) r = mid;
else l = mid;
}
cout << r << '\n';
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... |