| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 471924 | DDTerziev04 | Job Scheduling (CEOI12_jobs) | C++14 | 282 ms | 13660 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXM=1e6, MAXR=1e6;
pair<int, int> a[MAXM];
int GetEnd(int m, int cnt, int d)
{
int l=0, r=m-1, ans=-1;
while(l<=r)
{
int mid=l+(r-l)/2;
if(a[mid].first<=d)
{
ans=mid;
l=mid+1;
}
else
{
r=mid-1;
}
}
return ans;
}
bool CanProcess(int n, int d, int m, int cnt)
{
int prev=-1;
for(int i=0; i<n; i++)
{
int l=prev+1, r=min(prev+cnt, GetEnd(m, cnt, i+1));
if(r<l)
{
continue;
}
if(i-a[l].first+1>d)
{
return false;
}
if(r==m-1)
{
return true;
}
prev=r;
}
return false;
}
void PrintAns(int n, int d, int m, int cnt)
{
int prev=-1;
for(int i=0; i<n; i++)
{
int l=prev+1, r=min(prev+cnt, GetEnd(m, cnt, i+1));
if(r>=l)
{
for(int j=l; j<=r; j++)
{
cout << a[j].second+1 << " ";
}
prev=r;
}
cout << "0\n";
}
return;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, d, m;
cin >> n >> d >> m;
for(int i=0; i<m; i++)
{
cin >> a[i].first;
a[i].second=i;
}
sort(a, a+m);
int l=0, r=MAXR, ans;
while(l<=r)
{
int mid=l+(r-l)/2;
if(CanProcess(n, d, m, mid))
{
ans=mid;
r=mid-1;
}
else
{
l=mid+1;
}
}
cout << ans << "\n";
PrintAns(n, d, m, ans);
return 0;
}
/*
8 2 12
1 1 2 2 2 3 3 4 4 5 6 6
*/
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
