답안 #252616

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
252616 2020-07-25T23:28:55 Z ChrisT Stove (JOI18_stove) C++17
100 / 100
36 ms 2048 KB
#include<bits/stdc++.h>
using namespace std;
int main () {
	int n,k;
	scanf("%d %d", &n, &k);
	vector<int> v(n);
	for (auto &au : v) scanf("%d", &au);
	int ans = v[n-1] - v[0] + 1;
	vector<int> go(n-1);
	for (int i = 0; i + 1 < n; i++) go[i] = v[i+1] - v[i];
	sort(go.rbegin(),go.rend());
	for (int i = 0; i + 1 < k; i++) ans -= go[i] - 1;
	printf ("%d\n",ans);
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:5: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:7:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (auto &au : v) scanf("%d", &au);
                     ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 26 ms 2048 KB Output is correct
17 Correct 26 ms 2048 KB Output is correct
18 Correct 26 ms 2028 KB Output is correct
19 Correct 29 ms 2048 KB Output is correct
20 Correct 36 ms 2040 KB Output is correct
21 Correct 27 ms 2048 KB Output is correct
22 Correct 27 ms 2048 KB Output is correct
23 Correct 26 ms 2048 KB Output is correct
24 Correct 26 ms 2048 KB Output is correct