# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
498158 | MohamedFaresNebili | Job Scheduling (CEOI12_jobs) | C++14 | 350 ms | 20108 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define all(x) (x).begin() , (x).end()
int n, d, m; vector<ii> arr;
bool can(int val) {
int day[val]{0};
for(int l = 0, curr = 0; l < m; l++, curr = (curr + 1) % val) {
if(day[curr] + 1 - arr[l].ff > d) return 0;
day[curr] = max(day[curr] + 1, arr[l].ff);
}
return 1;
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> d >> m;
for(int l = 0; l < m; l++) {
int a; cin >> a; arr.pb({a, l});
}
sort(all(arr));
int lo = 0, hi = m, ans = -1;
while(lo <= hi) {
int md = (lo + hi + 1) / 2;
if(can(md)) { ans = md; hi = md - 1; }
else lo = md + 1;
}
cout << ans << "\n";
vector<int> res[n + 1]; int val[ans]{0};
for(int l = 0, curr = 0; l < m; l++, curr = (curr + 1) % ans) {
val[curr] = max(val[curr] + 1, arr[l].ff);
res[val[curr]].pb(arr[l].ss + 1);
}
for(int l = 1; l <= n; l++) {
for(auto u : res[l])
cout << u << " ";
cout << 0 << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |