답안 #972239

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972239 2024-04-30T09:19:47 Z vjudge1 Stove (JOI18_stove) C++17
100 / 100
39 ms 2136 KB
#include <bits/stdc++.h> 
#include <sstream> 
using namespace std; 
#define accepted ios_base::sync_with_stdio(false);cin.tie(nullptr); 
#define Daulbekov signed     
#define Makan main 
#define int long long 
#define double long double 
#define pb push_back 
#define pf push_front 
#define F first 
#define S second 
const int N=1e5+7; 
const int MAX=9e18+7; 
const int INF=1e18;
Daulbekov Makan(){
	int n,k;
	cin>>n>>k;
	k--;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	int x[n-1],ans=0;
	for(int i=0;i<n-1;i++){
		x[i]=a[i+1]-a[i];
		ans+=x[i];
	}
	sort(x,x+n-1);
	for(int i=n-2;i>=0;i--){
//		cout<<x[i]<<" ";
		if(k>=1){
			ans-=x[i];
			ans+=1;
			k--;
		}
		else{
			break;
		}
	}
	cout<<ans+1;
} 
// 1 2 5 6 8 11 13 16 20
//  2 4 2 3 4  3  4  5
//  2 1 2 3 1  1  1  1
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 34 ms 1972 KB Output is correct
17 Correct 37 ms 1872 KB Output is correct
18 Correct 35 ms 1876 KB Output is correct
19 Correct 35 ms 1876 KB Output is correct
20 Correct 34 ms 1972 KB Output is correct
21 Correct 35 ms 1972 KB Output is correct
22 Correct 35 ms 1872 KB Output is correct
23 Correct 39 ms 2136 KB Output is correct
24 Correct 34 ms 1872 KB Output is correct