Submission #754596

# Submission time Handle Problem Language Result Execution time Memory
754596 2023-06-08T06:46:23 Z matere Stove (JOI18_stove) C++14
100 / 100
54 ms 1208 KB
#include<bits/stdc++.h>
using namespace std;
vector<int>dist;
int n,k,a[200001];
int main(){
	cin>>n>>k;
	a[0]=-1999999999;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		dist.push_back(a[i]-a[i-1]-1);
	}
	int ans=n;
	sort(dist.begin(),dist.end());
	dist.pop_back();
	for(int i=1;i<=k-1;i++){
		dist.pop_back();
	}
	for(int i=0;i<dist.size();i++){
		ans+=dist[i];
	}
	cout<<ans<<endl;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:18:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i=0;i<dist.size();i++){
      |              ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 54 ms 1108 KB Output is correct
17 Correct 46 ms 1184 KB Output is correct
18 Correct 43 ms 1104 KB Output is correct
19 Correct 46 ms 1196 KB Output is correct
20 Correct 45 ms 1148 KB Output is correct
21 Correct 42 ms 1172 KB Output is correct
22 Correct 44 ms 1188 KB Output is correct
23 Correct 47 ms 1172 KB Output is correct
24 Correct 42 ms 1208 KB Output is correct