Submission #853169

# Submission time Handle Problem Language Result Execution time Memory
853169 2023-09-23T15:11:07 Z mall0809 Job Scheduling (CEOI12_jobs) C++17
0 / 100
333 ms 64288 KB
#include <bits/stdc++.h>

#define __gcd() gcd()
#define C int(1e6+7)
#define M int(1e9+7)
#define el '\n'
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
typedef long long ll;

vector<int> res[C],tmp[C];
int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);cout.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);

    int n,d,m;cin>>n>>d>>m;
    vector<array<int,2>> a(m);for(int i=0;i<m;i++)cin>>a[i][0],a[i][1] = i;
    sort(all(a));
    int l=1,r=1e7;
    auto check = [&](int mid){
        int id = 0,cnt=mid;
        for(int i=1;i<=n && id < m;i++){
            if(i > a[id][0] + d)return false;
            while(id < m && a[id][0] <= i && cnt>=1)cnt--,id++;
            cnt = mid;
        }
        return true;
    };
    while(l<r){
        int mid=(l+r)/2;
//        cout<<'#'<<mid<<el;
        if(check(mid))r=mid;
        else {
            for(int i=1;i<=n;i++)tmp[i].clear();
            l=  mid+1;
        }
    }
    cout<<r<<el;
    int cnt = r;
    for(int i=1,id=0;i<=n;i++){
        while(id < m && a[id][0] <= i && cnt >= 1){
            cout<<a[id][1]+1<<' ';
            cnt--,id++;
        }
        cnt = r;
        cout<<0<<el;
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 48728 KB Memory limit exceeded
2 Runtime error 37 ms 48732 KB Memory limit exceeded
3 Runtime error 36 ms 48696 KB Memory limit exceeded
4 Runtime error 38 ms 48808 KB Memory limit exceeded
5 Runtime error 36 ms 48708 KB Memory limit exceeded
6 Runtime error 38 ms 48724 KB Memory limit exceeded
7 Runtime error 37 ms 48728 KB Memory limit exceeded
8 Runtime error 37 ms 48724 KB Memory limit exceeded
9 Runtime error 56 ms 48724 KB Memory limit exceeded
10 Runtime error 46 ms 48724 KB Memory limit exceeded
11 Runtime error 44 ms 48708 KB Memory limit exceeded
12 Runtime error 84 ms 50236 KB Memory limit exceeded
13 Runtime error 117 ms 51544 KB Memory limit exceeded
14 Runtime error 159 ms 53064 KB Memory limit exceeded
15 Runtime error 175 ms 54648 KB Memory limit exceeded
16 Runtime error 230 ms 56404 KB Memory limit exceeded
17 Runtime error 288 ms 60824 KB Memory limit exceeded
18 Runtime error 290 ms 62036 KB Memory limit exceeded
19 Runtime error 333 ms 64288 KB Memory limit exceeded
20 Runtime error 285 ms 61012 KB Memory limit exceeded