# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
344458 | chienyu_xiong | Job Scheduling (CEOI12_jobs) | C++14 | 275 ms | 18056 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long int lli;
#define pll pair<lli, lli>
#define pil pair<int, lli>
#define pli pair<lli, int>
#define pii pair<int, int>
using namespace std;
void setIO(string str, bool dbg) {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (!dbg) {
freopen((str + ".in").c_str(), "r", stdin);
freopen((str + ".out").c_str(), "w", stdout);
}
}
const int MAX = 1e6 + 5;
const int LEN = 2e3 + 5;
const lli MOD = 1e9 + 7;
const lli INF = 1e17;
int _ = 1; // test cases
int n, m, d;
int arr[MAX];
int ord[MAX];
bool slv(int num) {
vector<int> cnt(num);
int cur = 0;
for (int i = 0; i < n; i++) {
cnt[cur] = max(arr[ord[i]], cnt[cur] + 1);
if (cnt[cur] - arr[ord[i]] > d)
return false;
cur = (cur + 1) % num;
}
return true;
}
bool cmp(int a, int b) {
return arr[a] < arr[b];
}
void fnc() {
cin >> n >> d >> m;
for (int i = 0; i < m; i++)
cin >> arr[i], ord[i] = i;
sort(ord, ord + m, cmp);
int lo = 1;
int hi = m;
while (lo < hi) {
int mid = (lo + hi + 0) / 2; // round down
bool can = slv(mid);
if (can == 1) hi = mid;
if (can == 0) lo = mid + 1;
}
cout << lo << "\n";
int cnt = 0;
for (int i = 1; i <= m; i++) {
cout << ord[i - 1] + 1 << " ";
if (i == m || i % lo == 0)
cout << "0\n", cnt++;
}
for (int i = cnt; i < n; i++)
cout << "0\n";
}
int main() {
setIO("", 1);
while (_--) fnc();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |