# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
743594 | vjudge1 | Job Scheduling (CEOI12_jobs) | C++17 | 191 ms | 13852 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+1;
int n,d,m;
struct job
{
int dline,idx;
bool operator <(const job &x)const{
if(dline != x.dline) return dline < x.dline;
}
};
int ans;
vector<job> vec;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> d >> m;
for(int i=1;i<=m;++i)
{
int x;
cin >> x;
x += d;
vec.push_back({x,i});
}
sort(vec.begin(),vec.end());
// while(!pq.empty())
// {
// cout << pq.top().dline << " " << pq.top().idx << '\n';
// pq.pop();
// }
int l = 1,r = 1e9+7;
while(l<=r)
{
int mid=(l+r)/2;
int day=1,cb = 0;
bool can = true;
// cout << "mid = " << mid << '\n';
for(int i=0;i<m;++i)
{
int num = day;
// cout << "day : " << num << " this job death line : " << vec[i].dline << '\n';
if(day >= vec[i].dline)
{
can = false;
break;
}
++cb;
if(cb == mid)
{
++day;
cb = 0;
}
}
if(can)
{
ans = mid;
r = mid-1;
}
else l = mid+1;
// cout << "\n\n";
}
cout << ans << '\n';
int cnt = 0;
for(int i=0;i<m;++i)
{
if(vec[i].dline != 0) cout << vec[i].idx << " ";
if((i+1)%ans == 0)
{
cout << "0\n";
++cnt;
}
}
while(cnt < n)
{
cout << "0\n";
cnt++;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |