답안 #754592

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
754592 2023-06-08T06:43:20 Z matere Stove (JOI18_stove) C++14
0 / 100
1 ms 340 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;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++){
      |              ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Runtime error 1 ms 340 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Runtime error 1 ms 340 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Runtime error 1 ms 340 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -