답안 #143792

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
143792 2019-08-15T06:46:43 Z WhipppedCream Stove (JOI18_stove) C++17
100 / 100
31 ms 2404 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	vector<int> arr(n);
	for(int i = 0; i< n; i++) scanf("%d", &arr[i]);
	vector<int> gap;
	for(int i = 0; i+1< n; i++) gap.pb(arr[i+1]-arr[i]-1);
	sort(gap.begin(), gap.end());
	reverse(gap.begin(), gap.end());
	int res = arr[n-1]-arr[0]+1;
	for(int i = 0; i< k-1; i++) res -= gap[i];
	printf("%d\n", res);
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:14: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:16:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i< n; i++) scanf("%d", &arr[i]);
                            ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 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 256 KB Output is correct
5 Correct 2 ms 256 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 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 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 256 KB Output is correct
5 Correct 2 ms 256 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 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 380 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 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 256 KB Output is correct
5 Correct 2 ms 256 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 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 380 KB Output is correct
12 Correct 3 ms 348 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 28 ms 2292 KB Output is correct
17 Correct 29 ms 2316 KB Output is correct
18 Correct 31 ms 2292 KB Output is correct
19 Correct 29 ms 2404 KB Output is correct
20 Correct 31 ms 2296 KB Output is correct
21 Correct 31 ms 2292 KB Output is correct
22 Correct 30 ms 2292 KB Output is correct
23 Correct 31 ms 2396 KB Output is correct
24 Correct 30 ms 2264 KB Output is correct