# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
118034 | Adhyyan1252 | Job Scheduling (CEOI12_jobs) | C++11 | 601 ms | 26836 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
//11 37
int n, d, m;
vector<pair<int, int> > a;
vector<vector<int> > g;
bool pos(int c, vector<vector<int> >& sch){
//is it poss to do it with c machines
sch.resize(n);
int pntr = 0;
for(int i = 0; i < n; i++){
for(int j : g[i]){
pntr = max(pntr, i);
while(pntr < n && sch[pntr].size() >= c){
pntr++;
}
if(pntr > i + d) return false;
sch[pntr].push_back(j);
}
}
return true;
}
int main(){
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>d>>m;
a.resize(m);
g.resize(n);
for(int i = 0; i < m; i++){
cin>>a[i].first; a[i].first--;
a[i].second = i;
g[a[i].first].push_back(i);
}
sort(a.begin(), a.end());
int low = 1, high = m, mid;
while(low < high){
mid = (low + high)/2;
//check if it is possible to do it with mid number of computers
vector<vector<int> > sch;
bool check = pos(mid, sch);
if(check){
high = mid;
}else{
low = mid+1;
}
}
mid = (low + high)/2;
vector<vector<int> > sch;
pos(mid, sch);
cout<<mid<<endl;
for(int i = 0; i < n; i++){
for(int j: sch[i]){
cout<<j+1<<" ";
}
cout<<0<<"\n";
}
cout.flush();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |