# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
923034 | MegatronRobo | Job Scheduling (CEOI12_jobs) | C++17 | 259 ms | 27280 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
int main(){
cin.tie(0)->sync_with_stdio(0);
int N, D, M;
cin>>N>>D>>M;
vector<int> req_counter(N+1);
vector<vector<int>> req_atDay(N+1);
for(int i=0;i<M;i++){
int a;
cin>>a;
req_counter[a]++;
req_atDay[a].push_back(i+1);
}
int lo=1, hi=M+1;
while(lo<hi){
int mid = lo+(hi-lo)/2; // no. of machines
vector<int> temp=req_counter;
for(int i=1;i<N;i++){
temp[i]=max(temp[i]-mid, 0);
temp[i+1]+=temp[i];
}
if(temp[N]<=mid){
// then possible
hi=mid;
}else{
lo=mid+1;
}
}
// we got our ans=lo
cout<<lo<<endl;
// need to show process
vector<vector<int>> reschedule;
reschedule.push_back({});
int curr_count=0;
for(int i=1;i<req_atDay.size();i++){
for(int j=0;j<req_atDay[i].size();j++){
if((curr_count+1)%lo==0){
curr_count=0;
reschedule.back().push_back(req_atDay[i][j]);
reschedule.push_back({});
}else{
curr_count++;
reschedule.back().push_back(req_atDay[i][j]);
}
}
}
if(reschedule.back()==vector<int>()){
reschedule.pop_back();
}
for(int i=0;i<N;i++){
if(i>=reschedule.size()){
goto other;
}
for(int j=0;j<lo;j++){
cout<<reschedule[i][j]<<" ";
}
other:;
cout<<0<<endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |