# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
340549 | iliccmarko | Watching (JOI13_watching) | C++14 | 2 ms | 384 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;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 1000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define single_case solve();
#define line cerr<<"----------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); }
#define mod 1000000007LL
ll n, p, q;
const int N = 2005;
ll a[N];
int main()
{
ios
cin>>n>>p>>q;
for(int i = 0;i<n;i++) cin>>a[i];
sort(a, a+n);
ll ans = 1e9;
ll l = 1;
ll r = 1e9;
while(l<=r)
{
ll mid = (r+l)/2;
ll poc = a[0];
ll pret = a[0];
vector<pair<ll, ll> > v;
ll cnt = 0;
for(ll i = 0;i<n;i++)
{
if(a[i] - poc>=mid)
{
cnt = 1;
v.pb({poc, pret});
poc = a[i];
pret = a[i];
}
else
{
pret = a[i];
}
}
v.pb({poc, pret});
ll c = 0;
ll qq = q;
ll pp = p;
for(ll i = 1;i<(ll)len(v);i++)
{
if(!qq) break;
ll raz = v[i].second - v[i-1].first;
if(raz<=2*mid)
{
qq--;
i--;
i+=2;
}
}
ll w = (ll)len(v) - (q-qq)*2;
if(qq+p>=w)
{
ans = mid;
r = mid - 1;
}
else
{
l = mid + 1;
}
}
cout<<ans;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |