제출 #650827

#제출 시각아이디문제언어결과실행 시간메모리
650827borisAngelovJob Scheduling (CEOI12_jobs)C++17
0 / 100
413 ms26308 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAXN = 100005;

int n, m, d;

vector<pair<int, int>> jobs;

pair<bool, vector<vector<int>>> check(int machines) {
    vector<vector<int>> schedule;
    schedule.resize(n + 1);

    int currJob = 0;

    for (int day = 1; day <= n; day++) {
        for (int j = 0; j < machines; j++) {
            if (jobs[currJob].first > day) break;

            if (jobs[currJob].first + d >= day) {
                schedule[day].push_back({jobs[currJob++].second});
            } else {
                return {false, schedule};
            }

            if (currJob == m) {
                return {true, schedule};
            }
        }
    }

    return {false, schedule};
}

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

    cin >> n >> d >> m;

    for (int i = 1; i <= m; i++) {
        int day; cin >> day;
        jobs.push_back({day, i});
    }

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

    int l = 1;
    int r = m;

    while (l <= r) {
        int mid = (l + r) / 2;

        if (check(mid).first) r = mid - 1;
        else l = mid + 1;
    }

    cout << l << endl;

    vector<vector<int>> schedule = check(l).second;

    for (int i = 1; i <= n; i++) schedule[i].push_back(0);

    for (int i = 1; i <= n; i++) {
        for (auto idx : schedule[i]) cout << idx << " "; cout << "\n";
    }

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

jobs.cpp: In function 'int main()':
jobs.cpp:67:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   67 |         for (auto idx : schedule[i]) cout << idx << " "; cout << "\n";
      |         ^~~
jobs.cpp:67:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   67 |         for (auto idx : schedule[i]) cout << idx << " "; cout << "\n";
      |                                                          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...