# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
740179 | Unforgettablepl | Job Scheduling (CEOI12_jobs) | C++17 | 369 ms | 23464 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
ID: samikgo1
TASK:
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
//#define f first
//#define s second
//#define x first
//#define y second
const int INF = INT32_MAX;
vector<pair<int,int>> jobs;
int n,d,m;
bool check(int machines, bool print){
// machines is the amount of machines we have
if(machines==0){return false;}
int day = 1;
int curr = 0;
vector<vector<int>> schedule(n);
for(auto&job:jobs){
while(job.first>day){
curr = 0;
day++;
}
if(day-job.first>d){
return false;
}
curr++;
schedule[day-1].emplace_back(job.second);
if(curr == machines){
day++;
curr = 0;
}
}
if(print){
cout << machines << '\n';
for(auto&i:schedule){
for(int&j:i){
cout << j << ' ';
}
cout << "0\n";
}
}
return true;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// freopen("measurement.in","r",stdin);
// freopen("measurement.out","w",stdout);
cin >> n >> d >> m;
jobs.resize(m);
for (int i = 0; i < m; i++) {
cin >> jobs[i].first;
jobs[i].second = i+1;
}
sort(all(jobs));
int l = 1;
int r = 1000000;
int ans = 1000000;
while(l<=r){
int mid = (l+r)/2;
if(check(mid,false)){
ans = min(ans,mid);
r = mid-1;
} else {
l = mid+1;
}
}
check(ans,true);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |