Submission #676983

# Submission time Handle Problem Language Result Execution time Memory
676983 2023-01-02T01:48:52 Z Dulguun Stove (JOI18_stove) C++11
100 / 100
45 ms 2020 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n,k,m;
	cin>>n>>k;
	int a[n], d[n-1];
	for(int &i: a) cin>>i;
	sort(a, a+n);
	m=a[n-1]-a[0]+1;
	for(int i=1; i<n; i++){
		d[i-1]=a[i]-a[i-1]-1;
	}
	sort(d, d+n-1, greater<int>());
	for(int i=0; i<n-1, k>1; k--, i++){
		m-=d[i];
	}
	cout << m;
	return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:15:16: warning: left operand of comma operator has no effect [-Wunused-value]
   15 |  for(int i=0; i<n-1, k>1; k--, i++){
      |               ~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 232 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 232 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 312 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 352 KB Output is correct
14 Correct 2 ms 316 KB Output is correct
15 Correct 2 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 232 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 312 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 352 KB Output is correct
14 Correct 2 ms 316 KB Output is correct
15 Correct 2 ms 316 KB Output is correct
16 Correct 44 ms 1996 KB Output is correct
17 Correct 43 ms 2020 KB Output is correct
18 Correct 43 ms 1996 KB Output is correct
19 Correct 45 ms 1944 KB Output is correct
20 Correct 43 ms 1928 KB Output is correct
21 Correct 43 ms 1948 KB Output is correct
22 Correct 43 ms 1948 KB Output is correct
23 Correct 43 ms 2020 KB Output is correct
24 Correct 43 ms 1952 KB Output is correct