Submission #104869

# Submission time Handle Problem Language Result Execution time Memory
104869 2019-04-09T12:06:59 Z daili Job Scheduling (CEOI12_jobs) C++14
0 / 100
691 ms 8676 KB
#include <bits/stdc++.h>

using namespace std;

bool check(vector<pair<int,int>> &allJobs, int currNr, int delay, int days)
{
    vector<int> used(days+1);
    for (int i = 0; i < allJobs.size(); i++)
    {
        int currentDay = allJobs[i].first;
        while(used[currentDay] >= currNr)
        {
            currentDay++;
        }
        if (currentDay > allJobs[i].first + delay)
        {
            return false;
        }
        used[currentDay]++;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, d, m;
    cin >> n >> d >> m;

    vector<pair<int,int>> allJobs;
    for (int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        allJobs.push_back({x, i+1});
    }

    sort(allJobs.begin(), allJobs.end());

    int left = 0;
    int right = m;

    while(left < right)
    {
        int mid = (left + right) >> 1;

        if (check(allJobs, mid, d, n))
        {
            right = mid;
        }
        else
        {
            left = mid + 1;
        }
    }

    if (check(allJobs, left, d, n))
    {
        cout << left << "\n";
    }
    else
    {
        cout << left +1 << "\n";
    }

}

Compilation message

jobs.cpp: In function 'bool check(std::vector<std::pair<int, int> >&, int, int, int)':
jobs.cpp:8:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < allJobs.size(); i++)
                     ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1532 KB Unexpected end of file - int32 expected
2 Incorrect 22 ms 1532 KB Unexpected end of file - int32 expected
3 Incorrect 17 ms 1532 KB Unexpected end of file - int32 expected
4 Incorrect 24 ms 1532 KB Unexpected end of file - int32 expected
5 Incorrect 18 ms 1532 KB Unexpected end of file - int32 expected
6 Incorrect 24 ms 1532 KB Unexpected end of file - int32 expected
7 Incorrect 16 ms 1532 KB Unexpected end of file - int32 expected
8 Incorrect 19 ms 1532 KB Unexpected end of file - int32 expected
9 Incorrect 25 ms 1532 KB Unexpected end of file - int32 expected
10 Incorrect 28 ms 1532 KB Unexpected end of file - int32 expected
11 Incorrect 34 ms 1532 KB Unexpected end of file - int32 expected
12 Incorrect 111 ms 2552 KB Unexpected end of file - int32 expected
13 Incorrect 81 ms 4588 KB Unexpected end of file - int32 expected
14 Incorrect 691 ms 4712 KB Unexpected end of file - int32 expected
15 Incorrect 130 ms 4596 KB Unexpected end of file - int32 expected
16 Incorrect 163 ms 8672 KB Unexpected end of file - int32 expected
17 Incorrect 198 ms 8672 KB Unexpected end of file - int32 expected
18 Incorrect 208 ms 8676 KB Unexpected end of file - int32 expected
19 Incorrect 237 ms 8676 KB Unexpected end of file - int32 expected
20 Incorrect 195 ms 8676 KB Unexpected end of file - int32 expected