# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
499605 | hades42 | Job Scheduling (CEOI12_jobs) | C++14 | 341 ms | 20732 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef tuple<ll, ll, ll> tp;
typedef pair<ll, ll> pr;
const ll MOD = 1000000007;
const ll INF = 1e18;
template <typename T> void print(const T &t) {
std::copy(t.cbegin(), t.cend(),
std::ostream_iterator<typename T::value_type>(std::cout, " "));
cout << endl;
}
template <typename T> void print2d(const T &t) {
std::for_each(t.cbegin(), t.cend(), print<typename T::value_type>);
}
void setIO(string s) { // the argument is the filename without the extension
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
ll n, d, m;
vector<pr> arr;
bool check(ll machine){
ll i = 0;
ll wait = 0;
ll currDay = 1;
ll count = 0;
while(i < m){
while(i < m && count < machine){
ll delay = max((ll)0, currDay - arr[i].first);
wait = max(delay, wait);
count++;
i++;
}
currDay++;
count = 0;
}
return wait > d;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
cin >> n >> d >> m;
arr.resize(m);
for(ll i = 0; i < m; i++){
ll num; cin >> num;
arr[i] = {num, i + 1};
}
sort(arr.begin(), arr.end());
//for(ll i = 0; i < n; i++){
//cout << arr[i].first << " " << arr[i].second << endl;
//}
ll left = 1;
ll right = m;
while(left < right){
ll mid = left + (right - left)/2;
if(check(mid)){
left = mid + 1;
} else{
right = mid;
}
}
ll need = left;
ll curr = 0;
ll count = 0;
cout << need << endl;
for(ll i = 0; i < n; i++){
while(count < need && curr < m){
cout << arr[curr].second << " ";
curr++;
count++;
}
count = 0;
cout << 0 << endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |