# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1085430 | AtinaR | Job Scheduling (CEOI12_jobs) | C++14 | 329 ms | 31212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
long long n,m,d;
const long long MAX=1e5+10;
const long long MMAX=1e6+10;
pair<long long,long long> niza[MMAX];
vector<long long> v[MAX];
bool can(long long x)
{
if(x<=0)return false;
if(x>=m)return true;
long long i=0;
for(long long day=1; day<=n; day++)
{
long long cnt=0;
while(i<m)
{
if(niza[i].first+d<day)return false;
else if(niza[i].first>day)break;
cnt++;
i++;
if(cnt==x)break;
}
}
if(i>=m)return true;
return false;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>d>>m;
for(long long i=0; i<m; i++)
{
cin>>niza[i].first;
niza[i].second=i+1;
}
sort(niza,niza+m);
long long b=0,e=m;
long long res=m;
while(b<=e)
{
long long mid=(b+e)/2;
if(can(mid))
{
res=mid;
e=mid-1;
}
else
{
b=mid+1;
}
}
long long i=0;
for(long long day=1; day<=n; day++)
{
long long cnt=0;
while(i<m)
{
if(niza[i].first>day)break;
v[day].push_back(niza[i].second);
cnt++;
i++;
if(cnt==res)break;
}
}
cout<<res<<endl;
for(long long i=1; i<=n; i++)
{
for(auto x:v[i])
{
cout<<x<<" ";
}
cout<<0<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |