Submission #41289

#TimeUsernameProblemLanguageResultExecution timeMemory
41289evpipisJob Scheduling (CEOI12_jobs)C++98
55 / 100
43 ms10404 KiB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
typedef pair<int, int> ii;

const int len = 1e5+5;
int n, d, m;
ii a[len];

bool check(int x){
    int po = 0;
    for (int i = 1; i <= n+1; i++){
        int temp = x;
        while (po < m && temp-- && a[po].fi <= i){
            if (i > d+a[po].fi) return false;
            po++;
        }
    }
    return true;
}

int bs(){
    int l = 1, r = m, ans;
    while (l <= r){
        int mid = (l+r)/2;
        if (check(mid)){
            ans = mid;
            r = mid-1;
        }
        else
            l = mid+1;
    }

    return ans;
}

int main(){
    scanf("%d %d %d", &n, &d, &m);
    for (int i = 0; i < m; i++){
        scanf("%d", &a[i].fi);
        a[i].se = i+1;
    }
    sort(a, a+m);

    int x = bs();
    printf("%d\n", x);

    int po = 0;
    for (int i = 1; i <= n; i++){
        int temp = x;
        while (po < m && temp-- && a[po].fi <= i){
            printf("%d ", a[po].se);
            po++;
        }
        printf("0\n");
    }

    return 0;
}

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:40:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &d, &m);
                                  ^
jobs.cpp:42:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i].fi);
                              ^
jobs.cpp: In function 'int bs()':
jobs.cpp:36:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return ans;
            ^
#Verdict Execution timeMemoryGrader output
Fetching results...