Submission #466114

# Submission time Handle Problem Language Result Execution time Memory
466114 2021-08-18T01:35:07 Z nehasane Job Scheduling (CEOI12_jobs) C++14
50 / 100
446 ms 13724 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, d, m;
    cin >> n >> d >> m;
    vector <pair<int, int>> jobs(m);
    for (int i = 0; i < m; i++){
        cin >> jobs[i].first;
        jobs[i].second = i;
    }
    sort(begin(jobs), end(jobs));
    int l = 1, r = m;
    while (l <= r){
        int mid = (l+r) / 2;
        int day = 1, i = 0, start = 0;
        while (i < m){
            for (i; i < min(m, start+mid); i++){
                if (day > jobs[i].first + d){
                    start = INT_MAX;
                    break;
                }
            }
            if (start == INT_MAX)
                break;
            else
                start = i;
            day++;
        }
        if (start == INT_MAX || day >= n)
            l = mid + 1;
        else
            r = mid - 1;
    }
    cout << l << '\n';
    int i = 0;
    for (int day = 0; day < n; day++){
        int end = i + l;
        for (i; i < min(m, end); i++)
            cout << jobs[i].second + 1 << ' ';
        cout << 0 << '\n';
    }


}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:18:18: warning: statement has no effect [-Wunused-value]
   18 |             for (i; i < min(m, start+mid); i++){
      |                  ^
jobs.cpp:39:14: warning: statement has no effect [-Wunused-value]
   39 |         for (i; i < min(m, end); i++)
      |              ^
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 1588 KB Output isn't correct
2 Incorrect 48 ms 1588 KB Output isn't correct
3 Incorrect 37 ms 1592 KB Output isn't correct
4 Incorrect 36 ms 1584 KB Output isn't correct
5 Incorrect 37 ms 1588 KB Output isn't correct
6 Incorrect 37 ms 1672 KB Output isn't correct
7 Incorrect 37 ms 1588 KB Output isn't correct
8 Incorrect 37 ms 1572 KB Output isn't correct
9 Correct 52 ms 1852 KB Output is correct
10 Correct 60 ms 1964 KB Output is correct
11 Correct 49 ms 1588 KB Output is correct
12 Incorrect 99 ms 3140 KB Output isn't correct
13 Correct 142 ms 4544 KB Output is correct
14 Incorrect 205 ms 6100 KB Output isn't correct
15 Correct 257 ms 7492 KB Output is correct
16 Correct 307 ms 9068 KB Output is correct
17 Correct 363 ms 10636 KB Output is correct
18 Correct 388 ms 12060 KB Output is correct
19 Correct 446 ms 13724 KB Output is correct
20 Correct 362 ms 10496 KB Output is correct