# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
333573 | siddarthm | Job Scheduling (CEOI12_jobs) | C++11 | 265 ms | 2796 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
using namespace std;
pair<int,int> orders[100000];
int n,d,m;
bool works(int x)
{
int point = 0;
//cout << x << endl;
for(int i=1; i<=n; i++)
{
for(int j=0; j<x; j++)
{
if(orders[point].first>i)
break;
if(i>(orders[point].first+d))
return false;
//cout << point << " ";
point++;
if(point==m)
break;
}
//cout << endl;
if(point==m)
break;
}
if(point<m)
return false;
return true;
}
int main(){
cin >> n >> d >> m;
for(int i=0; i<m; i++)
{
cin >> orders[i].first;
orders[i].second = i+1;
}
sort(orders, orders+m);
int a = 1;
int b = m;
while(a!=b)
{
int mid = (a+b)/2;
if(works(mid))
b = mid;
else
a = mid+1;
//cout << endl;
}
cout << a << endl;
int point = 0;
for(int i=1; i<=n; i++)
{
for(int j=0; j<a; j++)
{
if(point==m)
break;
if(orders[point].first>i)
break;
cout << orders[point].second << " ";
point++;
}
cout << 0 << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |