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