Submission #1165520

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
11655202025-03-12 02:17:58thinknoexitJob Scheduling (CEOI12_jobs)C++20
100 / 100
108 ms13608 KiB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> bucket[100100];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, d, m;
cin >> n >> d >> m;
for (int i = 1;i <= m;i++) {
int x;
cin >> x;
bucket[x].push_back(i);
}
int l = 1, r = m;
while (l < r) {
int mid = (l + r) / 2;
bool ch = 1;
queue<int> q;
for (int i = 1;i <= n;i++) {
if (!q.empty() && q.front() + d < i) {
ch = 0;
break;
}
for (int j = 0;j < (int)bucket[i].size();j++)
q.push(i);
for (int j = 1;j <= mid && !q.empty();j++) q.pop();
}
if (ch && q.empty()) r = mid;
else l = mid + 1;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...