# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
469853 | goatgm03 | Job Scheduling (CEOI12_jobs) | C++17 | 619 ms | 33416 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()
#define pii pair<int,int>
#define f first
#define s second
const int mx=1e6+5;
int n,d,m;
pair<bool,v<v<int> > > possible(const v<pii>t,int mid){
int cur=0;
v<v<int> >res(n);
for(int day=1;day<=n;day++){
for(int j=0;j<mid;j++){
if(t[cur].f>day){
break;
}
if(t[cur].f+d<day)
return {false,res};
else if(t[cur].f+d>=day){
res[day-1].pb(t[cur].s);
cur++;
}
if(cur==m){
return {true,res};
}
}
}
return {false,res};
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);
// clock_t startTime = clock();
cin>>n>>d>>m;
v<v<int> >ans;
v<pii>t(m);
for(int i=0;i<m;i++){
cin>>t[i].f;
t[i].s=i+1;
}
sort(t.begin(),t.begin()+m);
int lo=1,hi=m,sol=m;
while(lo<hi){
int mid=(hi+lo)/2;
pair<bool,v<v<int> > >c=possible(t,mid);
if(!c.f){
lo=mid+1;
}
else{
ans=c.s;
hi=mid;
}
}
cout<<lo<<endl;
/*while(lo<hi){
v<v<int> >result(n+1);
int mid=(hi+lo)/2;
int day=1,cur=0;
bool too_few_machines=false;
for(int day=1;day<=n;day++){
for(int j=0;j<mid;j++){
if(t[cur].f>day){
break;
}
if(t[cur].f+d>=day){
result[day].pb(t[cur].s);
cur++;
}
else if(t[cur].f+d<day){
too_few_machines=true;
break;
}
if(cur==m)
break;
else if(t[cur].f+d>=day&&t[cur].f<=day){
cur++;
}
}
}
if(!too_few_machines&&cur==m){
hi=mid;
sol=min(sol,mid);
ans=result;
// sol=min(sol,mid);
}
else{
lo=mid+1;
}
cout<<mid<<endl;
}
int day=1,cur=0;
v<v<int> >each_day(n+1);
cout<<sol<<endl;
for(int day=1;day<=n;day++){
for(int j=0;j<sol;j++){
if(t[cur].f>day){
break;
}
if(t[cur].f+d>=day){
each_day[day].pb(t[cur].s);
cur++;
}
}
}*/
for(int i=0;i<n;i++){
if((int)ans[i].size()==0){
cout<<"0\n";
continue;
}
for(int j:ans[i])
cout<<j<<' ';
cout<<"0\n";
}
// cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |