Submission #954199

#TimeUsernameProblemLanguageResultExecution timeMemory
954199irmuunWatching (JOI13_watching)C++17
0 / 100
93 ms31932 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n,p,q; cin>>n>>p>>q; ll a[n+5]; for(ll i=1;i<=n;i++){ cin>>a[i]; } if(p+q>=n){ cout<<1; return 0; } sort(a+1,a+n+1); ll l=1,r=1e9; ll dp[n+5][n+5]; while(l<r){ ll w=(l+r)/2; memset(dp,0,sizeof dp); for(ll sum=0;sum<=p+q;sum++){ for(ll i=0;i<=sum;i++){ if(i<=p&&sum-i<=q){ ll j=sum-i; if(i==0&&j==0){ dp[i][j]=0; continue; } ll nxt=0; if(i>0){ ll R=dp[i-1][j]+1; R=lower_bound(a+1,a+n+1,a[dp[i-1][j]+1]+w)-a; R--; dp[i][j]=max(dp[i][j],R); } if(j>0){ ll R=dp[i][j-1]+1; R=lower_bound(a+1,a+n+1,a[dp[i][j-1]+1]+2*w)-a; R--; dp[i][j]=max(dp[i][j],R); } } } } if(dp[p][q]==n){ r=w; } else{ l=w+1; } } cout<<l; }

Compilation message (stderr)

watching.cpp: In function 'int main()':
watching.cpp:38:24: warning: unused variable 'nxt' [-Wunused-variable]
   38 |                     ll nxt=0;
      |                        ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...