제출 #854395

#제출 시각아이디문제언어결과실행 시간메모리
854395anhphantJob Scheduling (CEOI12_jobs)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' ll N, D, M; pair<ll, ll> A[100007]; void initialize() { ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> D >> M; for(int i = 1; i <= M; ++i) { cin >> A[i].first; A[i].second = i; } sort(A + 1, A + 1 + M); } bool check(ll MachinesCnt) { int idx = 1; for(int day = 1; day <= N; ++day) { ll used_machines_in_day = 0; while(idx <= M && used_machines_in_day < MachinesCnt) { if (A[idx].first + D < day) return 0; if (day < A[idx].first) break; used_machines_in_day++; idx++; } } return idx > M; } void construct(ll MachinesCnt) { int idx = 1; for(int day = 1; day <= N; ++day) { ll used_machines_in_day = 0; while(idx <= M && used_machines_in_day < MachinesCnt) { if (A[idx].first + D < day) return 0; if (day < A[idx].first) break; cout << A[idx].second << " "; used_machines_in_day++; idx++; } cout << 0 << endl; } } void process() { ll l = 1, r = M; while(l < r) { ll mid = (l + r) / 2; if (check(mid)) r = mid; else l = mid + 1; } cout << l << endl; construct(l); } int main() { initialize(); process(); }

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

jobs.cpp: In function 'void construct(ll)':
jobs.cpp:44:48: error: return-statement with a value, in function returning 'void' [-fpermissive]
   44 |             if (A[idx].first + D < day) return 0;
      |                                                ^