| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 225792 | Andrei_Cotor | Job Scheduling (CEOI12_jobs) | C++11 | 331 ms | 27000 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<algorithm>
#include<deque>
#include<vector>
using namespace std;
vector<int> Jobs[100005];
vector<int> Rez[100005];
int Day[1000005];
int n,d;
bool possible(int capacity)
{
deque<int> Pending;
for(int i=1; i<=n; i++)
{
Rez[i].clear();
for(auto job:Jobs[i])
Pending.push_back(job);
for(int j=1; j<=capacity; j++)
{
if(Pending.empty())
break;
if(i-Day[Pending.front()]>d)
return 0;
Rez[i].push_back(Pending.front());
Pending.pop_front();
}
}
if(!Pending.empty())
return 0;
return 1;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int m;
cin>>n>>d>>m;
for(int i=1; i<=m; i++)
{
int x;
cin>>x;
Jobs[x].push_back(i);
Day[i]=x;
}
int rez=0;
for(int i=19; i>=0; i--)
{
if(!possible(rez+(1<<i)))
rez+=(1<<i);
}
rez++;
cout<<rez<<"\n";
possible(rez);
for(int i=1; i<=n; i++)
{
for(auto task:Rez[i])
cout<<task<<" ";
cout<<"0\n";
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
