제출 #678061

#제출 시각아이디문제언어결과실행 시간메모리
678061hello_there_123Stove (JOI18_stove)C++17
100 / 100
45 ms2216 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
main(){
	int N,K;
	cin>>N>>K;
	int ans = 0;
	int arr[N+3];
	for(int i=0;i<N;i++){
		cin>>arr[i];
	}
	ans = arr[N-1]-arr[0]+1;
	vector<int>v;
	for(int i=1;i<N;i++){
		v.push_back(arr[i]-arr[i-1]-1);
	}
	sort(v.begin(),v.end(),greater<int>());
	for(int i=0;i<K-1;i++){
		ans-=v[i];
	}
	cout<<ans;
	
}

컴파일 시 표준 에러 (stderr) 메시지

stove.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...