답안 #42089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42089 2018-02-22T10:56:41 Z nonocut Stove (JOI18_stove) C++14
100 / 100
33 ms 3116 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n,k;
int p[maxn];
int main() {
    int i,x,y;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++) {
        scanf("%d",&x);
        if(i) p[i] = x-y-1;
        y = x;
    }
    sort(p,p+n);
    int ans = n;
    for(i=0;i<n-k+1;i++) ans += p[i];
    printf("%d",ans);
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:8:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
                        ^
stove.cpp:10:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x);
                       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 1 ms 476 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 2 ms 588 KB Output is correct
9 Correct 1 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 1 ms 476 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 2 ms 588 KB Output is correct
9 Correct 1 ms 588 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 2 ms 672 KB Output is correct
12 Correct 2 ms 704 KB Output is correct
13 Correct 2 ms 736 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 2 ms 800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 1 ms 476 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 2 ms 588 KB Output is correct
9 Correct 1 ms 588 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 2 ms 672 KB Output is correct
12 Correct 2 ms 704 KB Output is correct
13 Correct 2 ms 736 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 2 ms 800 KB Output is correct
16 Correct 31 ms 1856 KB Output is correct
17 Correct 26 ms 2820 KB Output is correct
18 Correct 30 ms 3016 KB Output is correct
19 Correct 30 ms 3016 KB Output is correct
20 Correct 25 ms 3116 KB Output is correct
21 Correct 28 ms 3116 KB Output is correct
22 Correct 26 ms 3116 KB Output is correct
23 Correct 25 ms 3116 KB Output is correct
24 Correct 33 ms 3116 KB Output is correct