Submission #92107

#TimeUsernameProblemLanguageResultExecution timeMemory
92107tjrwodnjs999격자 보존하기 (GA9_preserve)C++11
65 / 100
34 ms2168 KiB
#include <bits/stdc++.h> using namespace std; int n,m,k,arr[100005],a[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+m-1,greater<int>()); for(int i=0;i<k/2;i++) sum+=a[i]; Max=sum; sum=arr[0]-1; for(int i=0;i<(k-1)/2;i++) sum+=a[i]; Max=max(Max,sum); sum=n-arr[m-1]; for(int i=0;i<(k-1)/2;i++) sum+=a[i]; Max=max(Max,sum); if(k>=2){sum=arr[0]-1; sum+=n-arr[m-1]; for(int i=0;i<(k-2)/2;i++) sum+=a[i]; Max=max(Max,sum);} printf("%d",Max); }

Compilation message (stderr)

preserve.cpp: In function 'int main()':
preserve.cpp:10:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(int i=0;i<k/2;i++) sum+=a[i]; Max=sum;
     ^~~
preserve.cpp:10:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for(int i=0;i<k/2;i++) sum+=a[i]; Max=sum;
                                       ^~~
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...