# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1094078 | Sunbae | Job Scheduling (CEOI12_jobs) | C++17 | 178 ms | 19028 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<int> v[100000];
int a[1000000];
signed main() {
int n, d, m;
scanf("%d %d %d", &n, &d, &m);
// Input reading
for(int i = 0; i < m; ++i) {
scanf("%d", a+i);
v[--a[i]].push_back(i); // Decrement a[i] before using it as an index
}
// Sorting the array
sort(a, a + m);
// Binary search
int low = 1, high = m, ans;
while(low <= high) {
int mid = low + ((high - low) >> 1), ch = 1;
for(int i = 0; i < m; ++i) {
if(i / mid > a[i] + d) { // Check this condition for correctness
ch = 0;
break;
}
}
if(ch) high = mid - 1, ans = mid;
else low = mid + 1;
}
// Output logic
int cnt = 0;
for(int i = 0, j; i < m; i = j, ++cnt) {
for(j = i; j < m && (i / ans) == (j / ans); ++j) {
printf("%d ", v[a[j]].back() + 1); // Print and pop
v[a[j]].pop_back();
}
puts("0"); // Add newline after each block
}
// Final trailing zeros
for(int j = 0; j < n - cnt - 1; ++j) puts("0"); // Newline after each "0"
printf("0\n"); // Final "0" with a newline
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |