제출 #650819

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

using namespace std;

const int MAXN = 100005;

int n, m, d;

vector<pair<int, int>> jobs;
vector<int> schedule[MAXN];

bool check(int machines) {
    for (int i = 1; i <= n; i++) {
        schedule[i].clear();
    }

    int currMachineIdx = 1;
    int currDay = 1;

    for (auto [day, idx] : jobs) {
        if (currDay > day + d) {
            return false;
        }

        schedule[currDay].push_back(idx);

        currMachineIdx++;
        if (currMachineIdx == machines + 1) {
            currMachineIdx = 1;
            currDay++;
        }
    }

    return true;
}

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)) r = mid - 1;
        else l = mid + 1;
    }

    cout << l << endl;

    check(l);

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