답안 #391507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
391507 2021-04-19T05:40:30 Z giorgikob Stove (JOI18_stove) C++14
100 / 100
25 ms 2380 KB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;

const int N = 4e5+5, mod = 3;

int n,k;
vector<int>v;
int A[N];
ll answer;

inline void test_case(){

    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> A[i];
    }

    for(int i = 1; i < n; i++){
        v.pb(A[i+1]-A[i]-1);
    }

    sort(v.begin(),v.end());

    for(int i = 0; i < n-k; i++){
        answer += v[i];
    }

    cout << answer+n << endl;
}

 main(){
    ios::sync_with_stdio(0);

    int T = 1;
    //cin >> T;
    while(T--){
        test_case();
    }
}

Compilation message

stove.cpp:35:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 |  main(){
      |       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 22 ms 2380 KB Output is correct
17 Correct 21 ms 2272 KB Output is correct
18 Correct 23 ms 2256 KB Output is correct
19 Correct 25 ms 2248 KB Output is correct
20 Correct 21 ms 2308 KB Output is correct
21 Correct 21 ms 2280 KB Output is correct
22 Correct 21 ms 2228 KB Output is correct
23 Correct 21 ms 2248 KB Output is correct
24 Correct 21 ms 2232 KB Output is correct