# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
142924 | jovan_b | Job Scheduling (CEOI12_jobs) | C++17 | 1087 ms | 18220 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];
set <pair <int, int>> q;
int n, d, m;
vector <int> resenje[100005];
bool check(int k){
for(int i=1; i<=n; i++){
resenje[i].clear();
}
for(int i=1; i<=n; i++){
for(auto c : vec[i]){
q.insert({i, c});
}
if(q.empty()) continue;
if(q.begin()->first < i-d) return 0;
int g = k;
while(!q.empty() && g--){
resenje[i].push_back(q.begin()->second);
q.erase(q.begin());
}
}
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... |