제출 #1318802

#제출 시각아이디문제언어결과실행 시간메모리
1318802theoneandonlytronJob Scheduling (CEOI12_jobs)C++20
0 / 100
350 ms29968 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long int; int n,d,m; bool check(ll a, deque <pair<ll,ll>> l1){ for (int i = 1; i <= n-d; i++){ for (int j = 0; j < a; j++){ if (l1[0].first > i){ break; } else if(l1[0].first + d < i){ return false; } l1.pop_front(); if (l1.size() == 0){ return true; } } } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> d >> m; deque <pair<ll,ll>> l1; for (int i = 0; i < m; i++){ ll a; cin >> a; l1.push_back({a, i+1}); } sort(l1.begin(), l1.end()); ll l = 1; ll r = m; while (l!=r){ ll mid_point = (l+r)/2; if (check(mid_point, l1)){ r = mid_point; } else{ l = mid_point + 1; } } for (int i = 1; i <= n; i++){ if (l1.size() == 0){ cout << 0 << "\n"; continue; } for (int j = 0; j < l; j++){ if (l1[0].first > i){ break; } cout << l1[0].second << " "; l1.pop_front(); if (l1.size() == 0){ break; } } cout << 0 << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...