# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
642566 | ymm | Job Scheduling (CEOI12_jobs) | C++17 | 235 ms | 24976 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
const int N = 200010;
const int M = 1000010;
vector<int> a[N];
int n, m, d;
bool bin(int x)
{
queue<int> q;
Loop (i,0,N) {
Loop (_,0,a[i].size())
q.push(i+d);
if (q.size() && q.front() <= i)
return 0;
for (int _=0; _<x && q.size(); ++_)
q.pop();
}
return 1;
}
vector<vector<int>> plan(int x)
{
vector<vector<int>> ans;
queue<int> q;
Loop (i,0,N) {
for (int j : a[i])
q.push(j);
ans.emplace_back();
for (int _=0; _<x && q.size(); ++_) {
ans.back().push_back(q.front());
q.pop();
}
}
return ans;
}
int main()
{
cin.tie(0) -> sync_with_stdio(false);
cin >> n >> d >> m; ++d;
Loop (i,0,m) {
int x;
cin >> x;
a[x-1].push_back(i+1);
}
int l = 1, r = m;
while (l < r) {
int mid = (l+r)/2;
if (bin(mid))
r = mid;
else
l = mid+1;
}
cout << l << '\n';
auto ans = plan(l);
Loop (i,0,n) {
for (int j : ans[i])
cout << j << ' ';
cout << "0\n";
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |