답안 #92132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92132 2019-01-01T15:33:11 Z tjrwodnjs999 격자 보존하기 (GA9_preserve) C++11
100 / 100
23 ms 1656 KB
#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);
    if(k>m*2) k=m*2;
    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

preserve.cpp: In function 'int main()':
preserve.cpp:11: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:11: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:8: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);
                          ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 380 KB Output is correct
22 Correct 2 ms 380 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 256 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1144 KB Output is correct
2 Correct 22 ms 1136 KB Output is correct
3 Correct 23 ms 1144 KB Output is correct
4 Correct 23 ms 1144 KB Output is correct
5 Correct 22 ms 1144 KB Output is correct
6 Correct 22 ms 1144 KB Output is correct
7 Correct 22 ms 1020 KB Output is correct
8 Correct 22 ms 1148 KB Output is correct
9 Correct 12 ms 760 KB Output is correct
10 Correct 8 ms 636 KB Output is correct
11 Correct 22 ms 1016 KB Output is correct
12 Correct 21 ms 1144 KB Output is correct
13 Correct 21 ms 1144 KB Output is correct
14 Correct 21 ms 1164 KB Output is correct
15 Correct 21 ms 1144 KB Output is correct
16 Correct 23 ms 1020 KB Output is correct
17 Correct 21 ms 1144 KB Output is correct
18 Correct 21 ms 1016 KB Output is correct
19 Correct 21 ms 1144 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 21 ms 1144 KB Output is correct
23 Correct 22 ms 1188 KB Output is correct
24 Correct 20 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1144 KB Output is correct
2 Correct 23 ms 1288 KB Output is correct
3 Correct 23 ms 1272 KB Output is correct
4 Correct 23 ms 1272 KB Output is correct
5 Correct 23 ms 1148 KB Output is correct
6 Correct 23 ms 1272 KB Output is correct
7 Correct 22 ms 1244 KB Output is correct
8 Correct 22 ms 1272 KB Output is correct
9 Correct 12 ms 896 KB Output is correct
10 Correct 8 ms 760 KB Output is correct
11 Correct 16 ms 1016 KB Output is correct
12 Correct 18 ms 1016 KB Output is correct
13 Correct 18 ms 1016 KB Output is correct
14 Correct 18 ms 1132 KB Output is correct
15 Correct 16 ms 1144 KB Output is correct
16 Correct 17 ms 1164 KB Output is correct
17 Correct 20 ms 1248 KB Output is correct
18 Correct 16 ms 1144 KB Output is correct
19 Correct 18 ms 1656 KB Output is correct
20 Correct 19 ms 1016 KB Output is correct