Submission #1257425

#TimeUsernameProblemLanguageResultExecution timeMemory
1257425cheetahStove (JOI18_stove)C++20
Compilation error
0 ms0 KiB
#include <iostream>
#include <stdio.h>
#include <queue>
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=100005;
int n,k;
vector<int>pont(maxn),dist(maxn);
/*
bool check(int sure){
	int k2=0;
	int pot=0;
	int i=1;
	while(i<n){
		pot+=pont[i]-pont[i-1];
		if(pot>=sure){
			pot=0;
			i++;
			k2++;
		}/*
		else if(){
			
		}*/
	} 
}*/
int32_t main(){
	int t=1;
	//cin>>t;
	while(t--){
		int n,ans;
		cin>>n>>k;
		ans=n;
		for(int i=0;i<n;i++){
			cin>>pont[i];
		}
		
		for(int i=0;i<n-1;i++){
			dist[i]=pont[i+1]-pont[i]-1;
		}
		sort(dist.begin(),dist.begin()+n-1);
		for(int i=0;i<n-k;i++){
			ans+=dist[i];
		}
		cout<<ans<<endl;
		/*
		int l=1,r=1000000005;
		while(l<=r){
			int mid=(l+r)>>1;
			if(check(mid)){
				r=mid;
			}
			else l=mid;
		}
		cout<<l<<endl;*/
	}
	
}

Compilation message (stderr)

stove.cpp:25:9: error: expected declaration before '}' token
   25 |         }
      |         ^
stove.cpp:26:1: error: expected declaration before '}' token
   26 | }*/
      | ^
stove.cpp:26:3: error: expected unqualified-id before '/' token
   26 | }*/
      |   ^