Submission #92121

#TimeUsernameProblemLanguageResultExecution timeMemory
92121tjrwodnjs999격자 보존하기 (GA9_preserve)C++11
17 / 100
24 ms2808 KiB
#include <bits/stdc++.h> using namespace std; int n,m,k,arr[100005],a[100005],b[100005],Max,sum; int main() { scanf("%d%d%d",&n,&m,&k); for(int i=0;i<m;i++) scanf("%d",&arr[i]); for(int i=0;i<m-1;i++) a[i]=arr[i+1]-arr[i]-1; sort(a,a+100005,greater<int>()); b[0]=a[0]; for(int i=1;i<m-1;i++) b[i]+=b[i-1]; if(k==1) Max=max(arr[0]-1,n-arr[m-1]); else{ Max=max(b[k/2-1],arr[0]-1+n-arr[m-1]); if(k>=3) Max=max(Max,b[(k-1)/2-1]+max(arr[0]-1,n-arr[m-1])); if(k>=4) Max=max(Max,b[(k-2)/2-1]+arr[0]-1+n-arr[m-1]); } printf("%d",Max); }

Compilation message (stderr)

preserve.cpp: In function 'int main()':
preserve.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&m,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~
preserve.cpp:7:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<m;i++) scanf("%d",&arr[i]);
                          ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...