# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
522321 | MOUF_MAHMALAT | Job Scheduling (CEOI12_jobs) | C++14 | 240 ms | 17176 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define all(s) s.begin(),s.end()
#define F first
#define S second
using namespace std;
typedef int ll;
ll n,d,m,x;
pair<ll,ll>a[1000009];
inline bool can(ll op)
{
ll r=0,i=1;
while(r<m)
{
ll o=0;
while(r<m&&a[r].F<=i&&o<op)
{
if(a[r].F+d<i)
return 0;
r++,o++;
}
i++;
}
return 1;
}
void go(ll op)
{
ll r=0,i=1;
while(r<m)
{
ll o=0;
while(r<m&&a[r].F<=i&&o<op)
{
cout<<a[r].S<<" ";
r++,o++;
}
cout<<0<<"\n";
i++;
}
while(i<=n){
cout<<0<<"\n";
i++;
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>n>>d>>m;
for(ll i=0;i<m;i++)
{
cin>>a[i].F;
a[i].S=i+1;
}
sort(a,a+m);
ll l=0,r=m,mid;
while(r-l>1)
{
mid=(l+r)/2;
if(can(mid))
r=mid;
else
l=mid;
}
cout<<r<<"\n";
go(r);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |