Submission #340539

#TimeUsernameProblemLanguageResultExecution timeMemory
340539iliccmarkoWatching (JOI13_watching)C++14
0 / 100
1 ms364 KiB
#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 int n, p, q; const int N = 2005; int a[N]; int main() { ios cin>>n>>p>>q; for(int i = 0;i<n;i++) cin>>a[i]; sort(a, a+n); int ans = 1e9; int l = 1; int r = 1e9; while(l<=r) { int mid = (r-l)/2 + l; int poc = a[0]; int pret = a[0]; vector<pair<int, int> > v; int cnt = 0; for(int 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}); int c = 0; int qq = q; int pp = p; for(int i = 1;i<len(v);i++) { int raz = v[i].second - v[i-1].first; if(raz<=2*mid-1) { qq--; i--; i+=2; } } int w = 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)

watching.cpp: In function 'int main()':
watching.cpp:38:13: warning: variable 'cnt' set but not used [-Wunused-but-set-variable]
   38 |         int cnt = 0;
      |             ^~~
watching.cpp:54:13: warning: unused variable 'c' [-Wunused-variable]
   54 |         int c = 0;
      |             ^
watching.cpp:56:13: warning: unused variable 'pp' [-Wunused-variable]
   56 |         int pp = p;
      |             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...