Submission #1251862

#TimeUsernameProblemLanguageResultExecution timeMemory
1251862selahaddin123Watching (JOI13_watching)C++20
Compilation error
0 ms0 KiB
#include<iostream> #include<vector> #include<algorithm> #include<climits> using namespace std; bool check(const vector<int> &A,int n,int P,int Q,int w){ int ma=min(Q,n); vector<vector<int>>dp(n+1,vector<int>(ma+1,INT_MAX)); dp[0][0]=0; for(int i=0;i<n;++i){ for(int q=0;q<=ma;++q){ if(dp[i][q]==INT_MAX)continue; int cover_until_small=A[i]+w-1; int j_small=upper_bound(A.begin(),A.end(),cover_until_small)-A.begin(); if(j_small<=n&&dp[j_small][q]>dp[i][q]+1){ dp[j_small][q]=dp[i][q]+1; } int cover_until_big=A[i]+2*w-1; int j_big=upper_bound(A.begin(),A.end(),cover_until_big)-A.begin(); if(q+1<=ma&&j_big<=n&&dp[j_big][q+1]>dp[i][q]){ dp[j_big][q+1]=dp[i][q]; } } } for(int q=0;q<=ma;++q){ if(dp[n][q]<=P)return true; } return false; } int main(){ int n,P,Q; cin>>n>>P>>Q; vector<int>A(n); for(int i=0;i<n;++i){ cin>>A[i]; } if(n==0){ cout<<0<<endl; return 0; } sort(A.begin(),A.end()); int low=1; int high=A[n-1]-A[0]+1; int ans=high; while(low<=high){ int mid=(low+high)/2; if(can_cover(A,n,P,Q,mid)){ ans=mid; high=mid-1; } else{ low=mid+1; } } cout<<ans<<endl; return 0; }

Compilation message (stderr)

watching.cpp: In function 'int main()':
watching.cpp:52:20: error: 'can_cover' was not declared in this scope
   52 |                 if(can_cover(A,n,P,Q,mid)){
      |                    ^~~~~~~~~