답안 #972258

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972258 2024-04-30T10:08:08 Z vjudge1 Stove (JOI18_stove) C++17
100 / 100
14 ms 2984 KB
/* 
 * imaN
 * 49
 * 
 * 
**/
#include <bits/stdc++.h>
using namespace std;
     
#define ll long long
#define FF first
#define SS second
#define pb push_back
#define bp pop_back()
#define int long long
#define ld long double
#define pf push_front
#define Imansoska ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl cout << "\n"
 
/*int binpow (int a, int n, int m) {
    if (n == 0)
        return 1%m;
    if (n % 2 == 1)
        return binpow (a, n-1,m) * a%m;
    else {
        int b = binpow (a, n/2,m);
        return b * b%m;
    }
}
 
int lcm(int a, int b) {
    return (a / __gcd(a, b)) * b;
}*/

const int N = (1e5+13);
const int maxn= 1e6+10;
const int MOD = 1e9 + 7;
const int INF = 1e18 + 7;

int z[N] , a[N];

signed main (/*Imansoska*/) {
	Imansoska
//	freopen("lepus.in","r",stdin);
//	freopen("lepus.out","w",stdout);
	int n,m;
	cin >> n >> m;
	int k=n-m;
	for ( int i=1; i<=n; i++ ) {
		cin >> z[i];
	}
	for ( int i=1; i<n; i++ ) {
		a[i]=z[i+1]-z[i];
	}
	sort(a+1,a+n);
	int s=m;
 	for (int i=1; i<=k; i++) {
 		s+=a[i];
	}
	cout<<s;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 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 480 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 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 480 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 624 KB Output is correct
16 Correct 14 ms 2908 KB Output is correct
17 Correct 14 ms 2896 KB Output is correct
18 Correct 14 ms 2908 KB Output is correct
19 Correct 14 ms 2968 KB Output is correct
20 Correct 14 ms 2904 KB Output is correct
21 Correct 14 ms 2908 KB Output is correct
22 Correct 14 ms 2908 KB Output is correct
23 Correct 14 ms 2984 KB Output is correct
24 Correct 14 ms 2908 KB Output is correct