# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
702261 | Uniq0rn | Job Scheduling (CEOI12_jobs) | C++14 | 227 ms | 13896 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define vi(x) vector<x>
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
vector<pair<int,int>> a;
int n,m,d;
bool check(int k){
int day = 1,cnt = 0;
for(int i=0;i<m;i++){
cnt++;
if(day-a[i].f > d) return false;
if(cnt > k || a[i].f > day){
day++;
cnt = 1;
}
}
//cout << k << ' ' << day << '\n';
return (day <= n);
}
void print(int k){
int day = 1,cnt = 0;
cout << k << '\n';
for(int i=0;i<m;i++){
cnt++;
if(cnt > k || a[i].f > day){
day++;
cnt = 1;
cout << 0 << '\n';
}
cout << a[i].s << ' ';
}
cout << 0 << '\n';
for(int i=0;i<n-day;i++){
cout << 0 << '\n';
}
}
int main()
{
cin.tie(nullptr)->ios_base::sync_with_stdio(false);
cin >> n >> d >> m;
a.resize(m);
for(int i=0;i<m;i++){
cin >> a[i].f;
a[i].s = i+1;
}
sort(all(a));
int l = 1,r = m;
while(l < r){
int mid = (l+r)>>1;
if(check(mid)){
r = mid;
}
else{
l = mid+1;
}
}
print(r);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |