# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
709906 | groshi | Job Scheduling (CEOI12_jobs) | C++17 | 357 ms | 17208 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
vector<pair<int,int> > Q;
int n,d,m;
void wypisz(int x)
{
cout<<x<<"\n";
queue<pair<int,int> > kolejka;
bool git=1;
int gdzie=0;
for(int i=1;i<=n;i++)
{
while(gdzie<Q.size() && Q[gdzie].first==i)
{
kolejka.push(Q[gdzie]);
gdzie++;
}
for(int j=1;j<=x;j++)
{
if(kolejka.size()==0)
break;
int kiedy=kolejka.front().first;
cout<<kolejka.front().second<<" ";
kolejka.pop();
}
cout<<"0\n";
}
}
bool git(int x)
{
queue<pair<int,int> > kolejka;
bool git=1;
int gdzie=0;
for(int i=1;i<=n;i++)
{
while(gdzie<Q.size() && Q[gdzie].first==i)
{
kolejka.push(Q[gdzie]);
gdzie++;
}
for(int j=1;j<=x;j++)
{
if(kolejka.size()==0)
break;
int kiedy=kolejka.front().first;
if(kiedy+d<i)
{
git=0;
break;
}
kolejka.pop();
}
if(git==0)
break;
}
if(git && kolejka.size()==0)
return 1;
else return 0;
}
int32_t main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int x;
cin>>n>>d>>m;
for(int i=1;i<=m;i++)
{
cin>>x;
Q.push_back({x,i});
}
sort(Q.begin(),Q.end());
int pocz=1,kon=m+1,sre,ostd;
while(pocz<kon)
{
sre=(pocz+kon)/2;
if(git(sre))
{
ostd=sre;
kon=sre;
}
else pocz=sre+1;
}
wypisz(ostd);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |