답안 #110076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110076 2019-05-09T09:18:47 Z maruii Stove (JOI18_stove) C++14
100 / 100
31 ms 2176 KB
#include<bits/stdc++.h>
using namespace std;
int N, K;
int A[100001], B[100001];
int main(){
	scanf("%d%d",&N,&K);
	for(int i=0; i<N; ++i)
		scanf("%d",A+i);
	for(int i=0; i<N-1; ++i)
		B[i] = A[i+1]-A[i];
	sort(B, B+N-1);
	int ans = accumulate(B, B+N-K, 0);
	printf("%d",ans+K);
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&N,&K);
  ~~~~~^~~~~~~~~~~~~~
stove.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",A+i);
   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 356 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 356 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 356 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 30 ms 2040 KB Output is correct
17 Correct 31 ms 2040 KB Output is correct
18 Correct 25 ms 2048 KB Output is correct
19 Correct 28 ms 2176 KB Output is correct
20 Correct 25 ms 2048 KB Output is correct
21 Correct 25 ms 2176 KB Output is correct
22 Correct 27 ms 2048 KB Output is correct
23 Correct 26 ms 2120 KB Output is correct
24 Correct 24 ms 2048 KB Output is correct