| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1327583 | hojiakbar2011 | Job Scheduling (CEOI12_jobs) | C++20 | 185 ms | 20916 KiB |
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ll long long
#define int long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
void setIO(string s) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
if (!s.empty()) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
}
signed main() {
setIO("");
ll n, d, m;
cin>>n>>d>>m;
vector<pair<ll,ll>> p(m);
for(int i=0;i<m;i++){
cin>>p[i].f;
p[i].f--;
p[i].s=i;
}
sort(all(p));
// for(auto u : p) cout<<u.f<<" "<<u.s<<"\n";
ll l=1, r=m;
while(l<r-1){
ll mid=(l+r)/2;
ll req=0;
bool ok=1;
for(int i=0;i<n;i++){
for(int j=0;j<mid;j++){
if(p[req].f>i) break;
if(i-p[req].f>d){
ok=0;
break;
}
req++;
if(req==m) break;
}
if(!ok || req==m) break;
}
if(req<m) ok=0;
if(ok) r=mid;
else l=mid;
}
cout<<r<<"\n";
ll req=0;
for(int i=0;i<n;i++){
for(int j=0;j<r;j++){
if(req==m) break;
if(p[req].f>i) break;
cout<<p[req].s+1<<" ";
req++;
}
cout<<0<<"\n";
}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
