# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
961019 | ankit_singh_programs | Job Scheduling (CEOI12_jobs) | C++14 | 1077 ms | 2548 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
#define ll long long
ll k;
#define str string
void io(str s){
str s1=s+".in";
str s2=s+".out";
freopen(s1.c_str(),"r",stdin);
freopen(s2.c_str(),"w",stdout);
}
#define de(x) cout<<#x<<" ";cout<<x<<endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int day,del,n;
#include <bits/stdc++.h>
#define ve vector
ve<pair<int,int>> ar;
#define f first
#define s second
bool chk(int k){
int a;
int c;
a=1;
c=0;
for(auto nxt:ar){
int v=nxt.f;
while(a<v){
++a;
c=0;
}
if(a>day) return 0;
int dt=fabs(a-v);
if(dt>del) return 0;
++c;
if(c==k){
c=0;
++a;
}
}
return 1;
}
const int inf=1e9;
#define pb push_back
#define all(x) (x).begin(),(x).end()
void sol(){
cin>>day>>del>>n;
for(int i=0;i<n;++i){
int a;
cin>>a;
ar.pb({a,i+1});
}
sort(all(ar));
int l=1;
int r=n;
int ans=inf;
while(l<=r){
int m=(l+r)/2;
if(chk(m)){
ans=m;
r=m-1;
}
else{
l=m+1;
}
}
// case t+ fasth
cout<<ans;
cout<<endl;
int k=ans;
int a,c;
a=1;
c=0;
bool don=0;
for(auto nxt:ar){
int v=nxt.f;
while(a<v){
cout<<"0\n";
++a;
c=0;
}
int dt=fabs(a-v);
++c;
cout<<nxt.second<<" ";
if(c==k){
don=1;
cout<<"0"<<endl;
c=0;
++a;
}
}
if(don);
else{
cout<<0<<endl;
++a;
}
a=day-a;
++a;
while(a--) cout<<0<<endl;
}
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
freopen("error.txt","w",stderr);
#endif
// io("cbarn2");
sol();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |