# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
869824 | amirhoseinfar1385 | Job Scheduling (CEOI12_jobs) | C++17 | 236 ms | 20052 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int n,d,m;
vector<pair<int,int>>all;
bool check(int mid){
int ret=1,now=0;
for(int i=0;i<m;i++){
if(all[i].first>ret){
ret++;
now=0;
i--;
continue;
}
if(ret>all[i].first+d){
return 0;
}
now++;
if(now==mid){
ret++;
now=0;
}
}
if(now==0){
ret--;
}
if(ret>n){
return 0;
}
return 1;
}
void co(int mid){
int ret=1,now=0;
vector<vector<int>>mainres(n+1);
for(int i=0;i<m;i++){
if(all[i].first>ret){
ret++;
now=0;
i--;
continue;
}
now++;
mainres[ret].push_back(all[i].second);
if(now==mid){
ret++;
now=0;
}
}
for(int i=1;i<=n;i++){
if((int)mainres[i].size()>mid){
assert(0);
}
for(auto x:mainres[i]){
cout<<x+1<<" ";
}
cout<<0<<"\n";
}
}
long long solve(){
long long low=0,high=1e9+5,mid;
while(high-low>1){
mid=(high+low)>>1;
if(check(mid)){
high=mid;
}
else{
low=mid;
}
}
return high;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>d>>m;
all.resize(m);
for(int i=0;i<m;i++){
cin>>all[i].first;
all[i].second=i;
}
sort(all.begin(),all.end());
int res=solve();
cout<<res<<"\n";
co(res);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |