# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1051853 | manhlinh1501 | Job Scheduling (CEOI12_jobs) | C++17 | 123 ms | 41556 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
const int MAXN = 1e6 + 5;
int N, M, D;
int a[MAXN];
vector<int> g[MAXN];
bool check(int K) {
queue<int> Q;
for(int i = 0; i <= N; i++) {
for(int p : g[i])
Q.emplace(p);
int cnt = 0;
while(!Q.empty() and cnt < K) {
int p = Q.front();
if(i - D > a[p])
return false;
Q.pop();
cnt++;
}
}
return Q.empty();
}
signed main() {
#define TASK "code"
if (fopen(TASK ".inp", "r")) {
freopen(TASK ".inp", "r", stdin);
freopen(TASK ".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N >> D >> M;
for(int i = 1; i <= M; i++)
cin >> a[i];
for(int i = 1; i <= M; i++) g[a[i]].emplace_back(i);
int low = 1, high = M;
int ans = -1;
while(low <= high) {
int mid = (low + high) / 2;
if(check(mid)) {
ans = mid;
high = mid - 1;
} else low = mid + 1;
}
cout << ans << "\n";
queue<int> Q;
for(int i = 0; i <= N; i++) {
for(int p : g[i])
Q.emplace(p);
int cnt = 0;
while(!Q.empty() and cnt < ans) {
int p = Q.front();
cout << p << " ";
Q.pop();
cnt++;
}
cout << "0\n";
}
return (0 ^ 0);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |