# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1264022 | mingga | Job Scheduling (CEOI12_jobs) | C++20 | 202 ms | 27608 KiB |
// Author: caption_mingle
#include "bits/stdc++.h"
using namespace std;
#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define ll long long
const int mod = 1e9 + 7;
const int inf = 2e9;
const int N = 1e5 + 7;
const int M = 1e6 + 7;
int n, d, m;
pair<int, int> a[M];
int cnt[M], tar[M];
vector<int> ev[N];
bool check(int mid) {
memset(cnt, 0, sizeof cnt);
int cur = 1;
for(int i = 1; i <= m; i++) {
if(a[i].fi > cur) {
cur = a[i].fi;
cnt[cur] = 1;
tar[i] = cur;
} else {
if(cnt[cur] == mid) {
cur++;
}
cnt[cur]++;
tar[i] = cur;
if(cur - a[i].fi > d) return 0;
}
}
return 1;
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
#define task ""
if(fopen(task ".INP", "r")) {
freopen(task ".INP", "r", stdin);
freopen(task ".OUT", "w", stdout);
}
cin >> n >> d >> m;
for(int i = 1; i <= m; i++) {
cin >> a[i].fi;
a[i].se = i;
}
sort(a + 1, a + m + 1);
int l = 1, r = m, ans = m;
while(l <= r) {
int mid = (l + r) >> 1;
if(check(mid)) {
r = mid - 1;
ans = mid;
} else l = mid + 1;
}
check(ans);
for(int i = 1; i <= m; i++) ev[tar[i]].pb(a[i].se);
cout << ans << ln;
for(int i = 1; i <= n; i++) {
for(int x : ev[i]) cout << x << ' ';
cout << 0 << ln;
}
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |