# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
862139 | vjudge1 | Job Scheduling (CEOI12_jobs) | C++14 | 205 ms | 21088 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
//#define int long long
int n,d,m;
vector<int> a,index_v;
bool is_ok(int machine)
{
int ptr=0;
for(int day=1;day<=n;++day)
{
for(int i=0;i<machine;++i)
{
if(ptr>=a.size()) return true;
if(a[ptr]>day) break;
if(a[ptr]+d<day) return false;
++ptr;
}
}
return (ptr>=a.size());
}
void yes(int machine)
{
int ptr=0;
for(int day=1;day<=n;++day)
{
for(int i=0;i<machine;++i)
{
if(ptr>=index_v.size()||a[ptr]>day) break;
cout<<index_v[ptr++]<<' ';
}
cout<<0<<'\n';
}
}
main()
{
ios::sync_with_stdio(0),cin.tie(0);
cin>>n>>d>>m;
vector<pair<int,int>> tmp(m);
for(int i=0;i<m;++i) cin>>tmp[i].first,tmp[i].second=i+1;
sort(tmp.begin(),tmp.end());
for(auto it:tmp) a.push_back(it.first),index_v.push_back(it.second);
int l=0,r=1e9,ans=1e9;
while(l<=r)
{
int mid=(r-l)/2+l;
if(is_ok(mid)) ans=mid,r=mid-1;
else l=mid+1;
}
cout<<ans<<'\n';
yes(ans);
return 0;
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |