Submission #361278

# Submission time Handle Problem Language Result Execution time Memory
361278 2021-01-29T07:06:17 Z parsabahrami Job Scheduling (CEOI12_jobs) C++17
5 / 100
292 ms 65536 KB
// Call my Name and Save me from The Dark
#include <bits/stdc++.h>
 
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
 
#define SZ(x)                       (int) x.size()
#define F                           first
#define S                           second

const int N = 1e6 + 10;
int n, D, m; pii A[N]; vector<int> vec[N];

int check(int x) {
    for (int i = 1, ptr = 0, cnt = 0; i <= n && ptr < m; i++) {
        if (i - A[ptr + 1].F > D) return 0;
        cnt = 0;
        while (ptr < m && A[ptr + 1].F <= i && cnt < x) ptr++, cnt++;
    }
    return 1;
}

void make(int x) {
    for (int i = 1, ptr = 0, cnt = 0; i <= n && ptr <= m; i++) {
        assert(i - A[ptr + 1].F <= D); 
        cnt = 0;
        while (ptr < m && A[ptr + 1].F <= i && cnt < x) {
            vec[i].push_back(A[ptr + 1].S);
            ptr++, cnt++;
        }
    }
}

int main() {
    scanf("%d%d%d", &n, &D, &m);
    for (int i = 1; i <= m; i++) scanf("%d", &A[i].F), A[i].S = i;
    sort(A + 1, A + m + 1);
    int l = 0, r = m + 1;
    while (r - l > 1) {
        int mid = (l + r) >> 1;
        if (check(mid)) r = mid;
        else l = mid;
    }
    printf("%d\n", r);
    make(r);
    for (int i = 1; i <= n; i++) {
        for (int j : vec[i]) {
            printf("%d ", j);
        }
        printf("0\n");
    }
    return 0;
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   37 |     scanf("%d%d%d", &n, &D, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:38:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   38 |     for (int i = 1; i <= m; i++) scanf("%d", &A[i].F), A[i].S = i;
      |                                  ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 62 ms 51052 KB Execution killed with signal 6
2 Runtime error 60 ms 51052 KB Execution killed with signal 6
3 Runtime error 61 ms 51052 KB Execution killed with signal 6
4 Runtime error 62 ms 51052 KB Execution killed with signal 6
5 Runtime error 60 ms 51052 KB Execution killed with signal 6
6 Runtime error 59 ms 51052 KB Execution killed with signal 6
7 Runtime error 60 ms 51052 KB Execution killed with signal 6
8 Runtime error 60 ms 51052 KB Execution killed with signal 6
9 Runtime error 70 ms 50924 KB Execution killed with signal 6
10 Runtime error 70 ms 50924 KB Execution killed with signal 6
11 Runtime error 69 ms 51180 KB Execution killed with signal 6
12 Correct 107 ms 28532 KB Output is correct
13 Runtime error 126 ms 58092 KB Execution killed with signal 6
14 Runtime error 175 ms 34412 KB Memory limit exceeded
15 Runtime error 209 ms 35104 KB Memory limit exceeded
16 Runtime error 210 ms 65536 KB Execution killed with signal 6
17 Runtime error 243 ms 65536 KB Execution killed with signal 6
18 Runtime error 284 ms 65536 KB Execution killed with signal 6
19 Runtime error 292 ms 65536 KB Execution killed with signal 6
20 Runtime error 254 ms 65536 KB Execution killed with signal 6