Submission #485754

# Submission time Handle Problem Language Result Execution time Memory
485754 2021-11-09T08:17:51 Z dongliu0426 Stove (JOI18_stove) C++17
100 / 100
23 ms 1656 KB
#include <bits/stdc++.h>
using namespace std;

#define N	100000

int main() {
	int n, k, ans;
	static int tt[N];

	scanf("%d%d", &n, &k), k--;
	for (int i = 0; i < n; i++)
		scanf("%d", &tt[i]);
	ans = tt[n - 1] - tt[0] + 1;
	for (int i = 0; i < n; i++)
		tt[i] = tt[i + 1] - tt[i] - 1;
	sort(tt, tt + n - 1);
	for (int i = 0; i < k; i++)
		ans -= tt[n - 1 - i - 1];
	printf("%d\n", ans);
	return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d%d", &n, &k), k--;
      |  ~~~~~^~~~~~~~~~~~~~~~
stove.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d", &tt[i]);
      |   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 0 ms 300 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 22 ms 1656 KB Output is correct
17 Correct 18 ms 1592 KB Output is correct
18 Correct 19 ms 1564 KB Output is correct
19 Correct 18 ms 1628 KB Output is correct
20 Correct 18 ms 1612 KB Output is correct
21 Correct 23 ms 1612 KB Output is correct
22 Correct 19 ms 1648 KB Output is correct
23 Correct 18 ms 1588 KB Output is correct
24 Correct 18 ms 1596 KB Output is correct