Submission #448077

# Submission time Handle Problem Language Result Execution time Memory
448077 2021-07-28T17:51:18 Z MohamedFaresNebili Job Scheduling (CEOI12_jobs) C++14
0 / 100
238 ms 16128 KB
// Author : Jad Isaac
// ID: jadDebugs
// TASK: -----
// LANG: C++                 
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f first
#define s second
#define pii pair<int, int>
 
int n, d, m;
 
bool works(int robots, vector<pii> jobs)
{
    int endT[robots] = {0};
    int maxD = 0;
 
    for (int i = 0, cur = 0; i < m; i++, cur++) {
        if (cur == robots)
            cur = 0;
        // if our end time for this job is > than our start time for this job
        // there will be delay
        if (endT[cur] + 1 > jobs[i].f) {
            endT[cur]++;
            maxD = max(maxD, endT[cur] - jobs[i].f);
        }
        else
            endT[cur] = jobs[i].f;
    }
    return maxD <= d;
}
 
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); 
 
    cin >> n >> d >> m;
 
    // first = day of req
    // second = id or req
    vector<pii> jobs(m);
 
    for (int i = 0; i < m; i++) {
        cin >> jobs[i].f;
        jobs[i].s = i+1;
    }
    sort(begin(jobs), end(jobs));
    int l = 0, r = m;
 
    while (l < r) {
        int mid = l + (r-l)/2;
        if (works(mid, jobs))
            r = mid;
        else
            l = mid+1;
    }
    cout << l << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 2124 KB Unexpected end of file - int32 expected
2 Incorrect 15 ms 2080 KB Unexpected end of file - int32 expected
3 Incorrect 15 ms 2124 KB Unexpected end of file - int32 expected
4 Incorrect 18 ms 2124 KB Unexpected end of file - int32 expected
5 Incorrect 16 ms 2076 KB Unexpected end of file - int32 expected
6 Incorrect 16 ms 2072 KB Unexpected end of file - int32 expected
7 Incorrect 15 ms 2084 KB Unexpected end of file - int32 expected
8 Incorrect 15 ms 2124 KB Unexpected end of file - int32 expected
9 Incorrect 23 ms 2124 KB Unexpected end of file - int32 expected
10 Incorrect 23 ms 2076 KB Unexpected end of file - int32 expected
11 Incorrect 23 ms 2080 KB Unexpected end of file - int32 expected
12 Incorrect 54 ms 3792 KB Unexpected end of file - int32 expected
13 Incorrect 72 ms 5660 KB Unexpected end of file - int32 expected
14 Incorrect 100 ms 7288 KB Unexpected end of file - int32 expected
15 Incorrect 122 ms 9164 KB Unexpected end of file - int32 expected
16 Incorrect 171 ms 10880 KB Unexpected end of file - int32 expected
17 Incorrect 185 ms 12692 KB Unexpected end of file - int32 expected
18 Incorrect 237 ms 14376 KB Unexpected end of file - int32 expected
19 Incorrect 238 ms 16128 KB Unexpected end of file - int32 expected
20 Incorrect 186 ms 12672 KB Unexpected end of file - int32 expected