# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
71517 | MathStudent2002 | Job Scheduling (CEOI12_jobs) | C++14 | 457 ms | 16396 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//wait darn
#include<bits/stdc++.h>
using namespace std;
#define MAXM 1000005
#define x first
#define y second
int M, N, D;
pair<int,int> job[MAXM];
void read()
{
ios_base::sync_with_stdio(false);
cin.tie();
cin >> N >> D >> M;
for(int i = 0; i < M; i++)
{
cin >> job[i].x;
job[i].y = i+1;
}
sort(job,job+M);
}
bool test(long long mech)
{
int d = 1;
int num = 0;
for(int i = 0; i < M;i++)
{
if(d > (job[i].x+D))
return false;
while(job[i].x > d)
{
d++;
num = 0;
}
num++;
if(num == mech)
{
d++;
num = 0;
}
}
return true;
}
void print(long long mech)
{
ios_base::sync_with_stdio(false);
cin.tie();
cout << mech << endl;
int d = 1;
int num = 0;
for(int i = 0; i < M;i++)
{
while(job[i].x > d)
{
d++;
num = 0;
cout << 0 << endl;
}
cout << job[i].y << " ";
num++;
if(num == mech)
{
d++;
num = 0;
cout << 0 << endl;
}
}
while(d <= N)
{
cout << 0 << endl;
d++;
}
}
int solve()
{
int lo = 1, hi = M, mi;
while(hi - lo > 1)
{
mi = (lo+hi)/2;
if(test(mi))
hi = mi;
else
lo = mi;
}
if(test(lo))
return lo;
return hi;
}
int main()
{
read();
print(solve());
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |