# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
142926 | jovan_b | Job Scheduling (CEOI12_jobs) | C++17 | 314 ms | 20344 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
vector <int> vec[100005];
int n, d, m;
vector <int> resenje[100005];
bool check(int k){
queue <pair <int, int>> q;
for(int i=1; i<=n; i++){
resenje[i].clear();
}
for(int i=1; i<=n; i++){
for(auto c : vec[i]){
q.push({i, c});
}
if(q.empty()) continue;
if(q.front().first < i-d) return 0;
int g = k;
while(!q.empty() && g--){
resenje[i].push_back(q.front().second);
q.pop();
}
}
return 1;
}
int main(){
ios_base::sync_with_stdio(false);
cout.precision(10);
cout<<fixed;
cin >> n >> d >> m;
for(int i=1; i<=m; i++){
int x;
cin >> x;
vec[x].push_back(i);
}
int l = 1, r = m, res = m;
while(l <= r){
int mid = (l+r)/2;
if(check(mid)){
res = mid;
r = mid-1;
}
else l = mid+1;
}
check(res);
cout << res << "\n";
for(int i=1; i<=n; i++){
for(auto c : resenje[i]) cout << c << " ";
cout << "0\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |