# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
469639 | goatgm03 | Job Scheduling (CEOI12_jobs) | C++17 | 1100 ms | 3788 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define v vector
#define all(x) x.begin(),x.end()
int main(){
int n,d,m;
cin>>n>>d>>m;
v<int>t(m);
for(int i=0;i<m;i++)
cin>>t[i];
sort(all(t));
int lo=1,hi=n,sol=n;
while(lo<hi){
int mid=(hi-lo)/2,cnt=0;
int day=1,cur=0;
for(int i=0;i<m;i++){
if(t[i]<=day&&day<=t[i]+d){
cnt++;
cur++;
}
if(cur==mid){
cur=0;
day++;
}
}
if(cnt<n){
lo=mid;
}
else{
hi=mid-1;
sol=min(sol,mid);
}
}
int mid=(hi-lo)/2,cnt=0;
int day=1,cur=0;
v<v<int> >each_day(n+1);
v<int>cur_day;
for(int i=0;i<m;i++){
if(t[i]<=day&&day<=t[i]+d){
cnt++;
cur++;
each_day[day].pb(t[i]);
}
if(cur==sol){
cur=0;
day++;
}
}
cout<<sol<<endl;
for(int i=1;i<=n;i++){
if(!each_day[i].size()){
cout<<"0\n";
continue;
}
for(int j:each_day[i]){
cout<<j<<' ';
}
cout<<"0\n";
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |