# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
442248 | cpp219 | Job Scheduling (CEOI12_jobs) | C++14 | 279 ms | 30936 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.
#pragma GCC optimization O2
#pragma GCC optimization "unroll-loop"
#pragma target ("avx2")
#include <bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 1e6 + 9;
const ll Log2 = 20;
const ll inf = 1e9 + 7;
ll n,m,d,a[N],pos[N];
bool lf(ll x,ll y){
return a[x] < a[y];
}
vector<ll> ans[N];
bool chk(ll mid){
ll cur = 1;
for (ll day = 1;day <= n;day++){
ll have = mid; ans[day].clear();
while(have > 0 && cur <= m&&a[pos[cur]] <= day){
if (day - a[pos[cur]] > d) return 0;
//ans[day].push_back(pos[cur]);
cur++; have--;
}
//ans[day].push_back(0);
}
return 1;
}
int main(){
ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define task "test"
if (fopen(task".INP","r")){
freopen(task".INP","r",stdin);
//freopen(task".OUT","w",stdout);
}
cin>>n>>d>>m;
for (ll i = 1;i <= m;i++) cin>>a[i],pos[i] = i;
sort(pos + 1,pos + m + 1,lf);
ll l,mid,h; l = 1; h = m;
//cout<<chk(2); return 0;
while(l <= h){
mid = (l + h)/2;
if (chk(mid)) h = mid - 1;
else l = mid + 1;
}
cout<<l<<"\n"; chk(l); //return 0;
for (ll i = 1;i <= n;i++){
for (auto j : ans[i]) cout<<j<<" "; cout<<"\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |