# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
446569 | ArianKheirandish | Job Scheduling (CEOI12_jobs) | C++14 | 1097 ms | 29328 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//in the name of god//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define MP make_pair
const int maxn = 1e6 + 10;
const int LG = 30;
const ll Inf = 1e9;
int n, d, m;
pair<int, int> a[maxn];
bool check(int x){
int now = 1;
int z = 0;
for(int i = 0 ; i < m ; i ++){
if(a[i].F > now)
now = a[i].F,
z = 1;
else if(a[i].F < now - d)
return 0;
else if(a[i].F >= now - d)
z ++;
if(z >= x)
z = 0,
now ++;
}
return 1;
}
int main(){_
cin >> n >> d >> m;
for(int i = 0; i < m ; i ++){
cin >> a[i].F;
a[i].S = i + 1;
}
sort(a, a + m);
int l = 0, r = m;
while(l < r - 1){
int mid = (l + r) / 2;
if(check(mid))
r = mid;
else
l = mid;
}
cout << r << '\n';
int now = 1;
int z = 0;
for(int i = 0; i < m ; i ++){
if(a[i].F > now){
for (int j = now ; j < a[i].F; j ++)
cout << 0 << '\n';
n = a[i].F;
z = 1;
}
else if (a[i].F >= now - d){
cout << a[i].S << " ";
z ++;
}
if(z >= r){
cout << 0 << '\n';
z = 0;
now ++;
}
}
for (int i = now ; i <= n ; i ++)
cout << 0 << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |