# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
50663 | AryanSM | Job Scheduling (CEOI12_jobs) | C++17 | 698 ms | 59908 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define ld long double
int const M=1e6+10,M2=1e7+10,mod=1e9+7,inf=1e9+10;
int m,d,a[M],n;
vector<int>hlp[M];
vector<pii>all;
bool check(int x,bool ch)
{
int day=1,cnt=0;
for(int i=0;i<m;i++)
{
if(cnt==x)day++,cnt=0;
if(day>n)return 0;
if(day<all[i].F)day=all[i].F,cnt=0;
if(day>all[i].F+d)return 0;
if(ch)hlp[day].pb(all[i].S);
cnt++;
}
return 1;
}
int32_t main()
{
cin>>n>>d>>m;
for(int i=1;i<=m;i++)
{
cin>>a[i];
all.pb(mp(a[i],i));
}
sort(all.begin(),all.end());
int lo=1,hi=m;
while(hi>lo+1)
{
int mid=(lo+hi)/2;
if(check(mid,0))hi=mid;
else lo=mid+1;
}
int ans=hi;
if(check(lo,0))ans=lo;
check(ans,1);
cout<<ans<<endl;
int cnt=0;
for(int i=1;i<=n;i++)
{
for(int j=0;j<hlp[i].size();j++)cout<<hlp[i][j]<<" ";
cout<<0<<endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |