# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
78543 | hamzqq9 | Job Scheduling (CEOI12_jobs) | C++14 | 578 ms | 20736 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>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2000000000
#define MOD 1000000007
#define N 100005
#define MAX 5000000
#define LOG 100
#define KOK 333
using namespace std;
int n,d,m,x;
vector<ii> v;
void solve(int val) {
for(int i=1;i<=n;i++) {
int tot=0;
while(tot+1<=val && sz(v) && v.back().st<=i) {
printf("%d ",v.back().nd);
v.ppb();
tot++;
}
printf("0\n");
}
}
bool ok(int val) {
vector<int> now;
for(ii i:v) now.pb(i.st);
for(int i=1;i<=n;i++) {
int tot=0;
while(tot+1<=val && sz(now) && now.back()<=i) {
now.ppb();
tot++;
}
if(sz(now) && i-now.back()>d) return false;
}
return true;
}
int main() {
//freopen("input.txt","r",stdin);
scanf("%d %d %d",&n,&d,&m);
for(int i=1;i<=m;i++) {
scanf("%d",&x);
v.pb({x,i});
}
sort(all(v),greater<ii>());
int bas=1,son=m;
while(bas<=son) {
if(ok(orta)) son=orta-1;
else bas=orta+1;
}
printf("%d\n",bas);
solve(bas);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |