# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
653998 | roimu | Job Scheduling (CEOI12_jobs) | C++17 | 465 ms | 24972 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
using namespace std;
typedef long long LL;
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18
LL n, d, m;
bool f(LL mid,const vector<pair<LL,LL>>& jobs,const vector<LL>& rui) {
int p = 0;
for (int i = 1; i <= n; i++) {
if (jobs[p].first>(i+d))return false;
if (jobs[p].first > i)continue;
p = min(p + mid, rui[i]);
if (p == m)return true;
}
if (p == m)return true;
return false;
}
int main() {
cin >> n >> d >> m;
vector<pair<LL, LL>> jobs;
for (int i = 0; i < m; i++) {
LL x; cin >> x;
jobs.push_back({ x,i + 1 });
}
sort(jobs.begin(), jobs.end());
vector<LL> rui(n + 1);
int nowd = 1;
for (int i = 0; i < m; i++) {
if (nowd == jobs[i].first) {
rui[nowd]++;
}
else {
nowd = jobs[i].first;
rui[nowd] = rui[nowd - 1] + 1;
}
}
//機械の数を決め打ち、多いほうが達成しやすい
LL ng = 0; LL ok = 1000010;
while (abs(ng - ok) > 1) {
LL mid = min(ng, ok) + abs(ng - ok) / 2;
if (f(mid,jobs,rui)) {
ok = mid;
}
else {
ng = mid;
}
}
cout << ok << endl;
int p = 0;
for (int i = 1; i <= n; i++) {
int cnt = ok;
while (p<m&&jobs[p].first<= i) {
if (cnt == 0)break;
cout << jobs[p].second << " ";
p++;
cnt--;
}cout << 0 << endl;
}
return 0;
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |