답안 #753460

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753460 2023-06-05T09:13:51 Z IvanJ Stove (JOI18_stove) C++17
100 / 100
32 ms 2256 KB
#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define all(a) (a).begin(), (a).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 1e5 + 5;

int n, k;
int t[maxn];

int main() {
	scanf("%d%d", &n, &k);
	for(int i = 0;i < n;i++) 
		scanf("%d", t + i);
	
	sort(t, t + n);
	int T = t[n - 1] - t[0] + 1;
	
	vector<int> v;
	for(int i = 1;i < n;i++) 
		v.pb(t[i] - t[i - 1] - 1);
	sort(all(v));
	reverse(all(v));
	for(int i = 0;i < k - 1;i++) 
		T -= v[i];
	printf("%d\n", T);
	return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  scanf("%d%d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~
stove.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d", t + i);
      |   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 22 ms 2220 KB Output is correct
17 Correct 21 ms 2188 KB Output is correct
18 Correct 23 ms 2236 KB Output is correct
19 Correct 25 ms 2256 KB Output is correct
20 Correct 22 ms 2232 KB Output is correct
21 Correct 32 ms 2224 KB Output is correct
22 Correct 22 ms 2232 KB Output is correct
23 Correct 21 ms 2192 KB Output is correct
24 Correct 20 ms 2256 KB Output is correct