# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
465151 | tphuc2908 | Job Scheduling (CEOI12_jobs) | C++14 | 391 ms | 13780 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define repi(i,x,y) for(int i = x; i >= y; --i)
#define ci(x) int x; cin>> x
#define TC(t) ci(t); while(t--)
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define cii(x, y) ci(x); ci(y)
typedef long long ll;
typedef vector<int> vi;
const int N = 1e6 + 5;
const int mod = 1e9+7;
const int inf = 1e9 + 5;
void readfile(){
#ifdef ONLINE_JUDGE
#else
freopen("text.inp", "r", stdin);
#endif // ONLINE_JUDGE
// freopen("angry.in", "r", stdin);
// freopen("angry.out", "w", stdout);
}
int n, d, m;
pair<int,int> a[N];
void inp(){
cin >> n >> d >> m;
rep(i,1,m){
cin >> a[i].fi;
a[i].se = i;
}
sort(a + 1, a + m + 1);
}
bool check(int x){
int j = 1;
queue<pair<int,int> > q;
rep(i,1,n){
while(j <= m && a[j].fi==i){
q.push(a[j]);
++j;
}
int cnt = 0;
while(cnt < x && !q.empty()){
if(i - q.front().fi > d)
return 0;
q.pop();
++cnt;
}
}
return q.empty();
}
void process(){
int l = 1, r = m, res;
while(l <= r){
ll mid = (l + r) >> 1;
if(check(mid)){
res = mid;
r = mid - 1;
}
else l = mid + 1;
}
cout << res << '\n';
queue<pair<int,int> > q;
int j = 1;
rep(i,1,n){
while(j <= m && a[j].fi==i){
q.push(a[j]);
++j;
}
int cnt = 0;
while(cnt < res && !q.empty()){
cout << q.front().se << ' ';
q.pop();
++cnt;
}
cout << 0 << '\n';
}
}
int main(){
// readfile();
ios_base::sync_with_stdio(0);
cin.tie(0);
inp();
process();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |