제출 #263389

#제출 시각아이디문제언어결과실행 시간메모리
263389DS007Job Scheduling (CEOI12_jobs)C++14
0 / 100
1098 ms11052 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N = 1e5, M = 1e6;
int a[M], n, d, m;

bool check(int mid) {
    queue<int> q;
    for (int i = 1, p = 0; i <= n; i++) {
        while (p < m && a[p] == i)
            q.push(a[p++]);

        for (int j = 0; j < mid && !q.empty(); j++) {
            if (i - q.front() > d)
                return false;
            q.pop();
        }
    }

    return true;
}

int solveTestCase() {
    cin >> n >> d >> m;
    for (int i = 0; i < m; i++) cin >> a[i];
    sort(a, a + m);

    int l = 1, h = M, ans = M;
    while (l <= h) {
        //cerr << l << " " << h << "\n";
        int mid = (l + h) / 2;
        if (check(mid))
            ans = mid, h = mid - 1;
        else
            l = mid + 1;
    }

    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
    //cin >> t;
    while (t--)
        solveTestCase();
}


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

jobs.cpp: In function 'long long int solveTestCase()':
jobs.cpp:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
   40 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...