# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
364257 | _martynas | Swimming competition (LMIO18_plaukimo_varzybos) | C++11 | 513 ms | 13036 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;
#define pb push_back
const ll INF = 1e13;
const int MAX_N = 1e6+5;
int N, A, B;
int T[MAX_N];
bool check_t(int c_t)
{
deque<int> I;
I.pb(-1);
int i = 0;
while(i < N && !I.empty())
{
int curr_i = I.front();
if(i - curr_i >= A)
{
if(i - curr_i <= B && T[i] - T[curr_i + 1] <= c_t)
{
I.pb(i);
i++;
}
else
{
I.pop_front();
}
}
else
{
i++;
}
}
return !I.empty() && I.back() == N-1;
}
int bin_search()
{
int l = 0, r = T[N-1];
int mid;
while(l < r)
{
mid = l + (r-l) / 2;
bool can = check_t(mid);
if(can)
{
r = mid;
}
else
{
l = mid+1;
}
}
return l;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
scanf("%d%d%d", &N, &A, &B);
for(int i = 0; i < N; i++)
{
scanf("%d", &T[i]);
}
sort(T, T + N);
int ans = bin_search();
cout << ans << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |