# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
478502 | FluffyGhost8 | Job Scheduling (CEOI12_jobs) | C++17 | 1096 ms | 19484 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <array>
#include <fstream>
#include <cmath>
#include <string>
#include <numeric>
#include <tuple>
#include <unordered_map>
#include <queue>
#include <unordered_set>
using namespace std;
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define pb push_back
bool works(ll mid);
ll n, d, m;
ll low = 1;
ll high = m;
vector<pll> v;
ll input;
int main()
{
cin >> n >> d >> m;
high = m;
for(int i = 0; i < m; i++)
{
cin >> input;
v.pb(mp(input-1, input+d-1));
}
sort(v.begin(), v.end());
ll ans;
//cout << "hello" << " " << low << " " << high << endl;
while(low <= high)
{
ll mid = low+(high-low)/2;
//cout << mid << " " << works(mid) << endl;
if(works(mid))
{
ans = mid;
high = mid-1;
} else {
low = mid+1;
}
}
cout << ans << endl;
}
bool works(ll mid)
{
int pos = 0;
int pschng;
//cout << endl << endl << mid << endl << endl;
for(int i = 0; i < n; i++)
{
pschng = 0;
for(int j = pos; j < (pos+mid); j++)
{
if(j >= v.size())
{
break;
}
if(v[j].second < i)
{
return false;
}
if(v[j].first <= i)
{
pschng++;
}
//cout << i << " " << j << " " << v[j].first << " " << v[j].second << " " << pos << endl;
}
pos += pschng;
}
return true;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |