# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
132223 | amoo_safar | Job Scheduling (CEOI12_jobs) | C++14 | 206 ms | 23672 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 10;
vector<int> rec[Maxn], op[Maxn];
int cnt[Maxn];
int n, m, d;
bool check(int c){
for(int i = 1; i <= n; i++) cnt[i] = rec[i].size();
int p = 1, done = 0, free, rem;
for(int i = 1; i <= n; i++){
p = max(p, i - d);
free = c;
while((p <= i) && (free)){
rem = min(free, cnt[p]);
free -= rem;
cnt[p] -= rem;
done += rem;
if(cnt[p] == 0) p++;
}
}
return (done == m);
}
void solve(int c){
int p = 1, free;
for(int i = 1; i <= n; i++){
p = max(p, i - d);
free = c;
while((p <= i) && (free)){
if(rec[p].size() == 0){
p ++;
continue;
}
free --;
op[i].pb(rec[p].back());
rec[p].pop_back();
}
}
return ;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> d >> m;
int v;
for(int i = 1; i <= m; i++){
cin >> v;
rec[v].pb(i);
}
int l = 0, r = n, mid;
while(l + 1 < r){
mid = (l + r) >> 1;
if(check(mid)) r = mid;
else l = mid;
}
cout << r << '\n';
solve(r);
for(int i = 1; i <= n; i++){
for(auto x : op[i]) cout << x << " ";
cout << "0\n";
}
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... |