# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
557650 | Hanksburger | Job Scheduling (CEOI12_jobs) | C++17 | 256 ms | 17204 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
pair<int, int> b[1000005];
queue<pair<int, int> > q;
int a[100005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, d, m, l=1, r=1e6, index=1;
cin >> n >> d >> m;
for (int i=1; i<=m; i++)
{
cin >> b[i].first;
b[i].second=i;
a[b[i].first]++;
}
sort(b+1, b+m+1);
while (l<r)
{
int mid=(l+r)/2;
bool ok=1;
for (int i=1; i<=n; i++)
{
if (a[i])
q.push({i, a[i]});
int cnt=mid;
while (q.size() && cnt>=q.front().second)
{
cnt-=q.front().second;
q.pop();
}
if (q.size())
{
if (q.front().first<=i-d)
{
ok=0;
break;
}
q.front().second-=cnt;
}
}
if (ok)
r=mid;
else
l=mid+1;
while (q.size())
q.pop();
}
cout << l << '\n';
for (int i=1; i<=n; i++)
{
while (index<=m && b[index].first==i)
{
q.push({b[index].second, 0});
index++;
}
int cnt=l;
while (q.size() && cnt)
{
cout << q.front().first << ' ';
cnt--;
q.pop();
}
cout << 0 << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |