답안 #330132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
330132 2020-11-24T03:09:28 Z eric_xiao Stove (JOI18_stove) C++14
100 / 100
52 ms 2148 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long A[500000];
vector<ll> te;
int main()
{
    ll N,M,i,j,k;
    cin >> N >> k;
    for(i = 0;i < N;i++)
    {
        cin >> A[i];
        if(i > 0) te.push_back(A[i]-A[i-1]-1);
    }
    ll ans = A[N-1]-A[0]+1;
    sort(te.begin(),te.end());
    reverse(te.begin(),te.end());
    for(i = 0;i < k-1;i++)
    {
        ans -= te[i];
    }
    cout << ans << endl;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:8:10: warning: unused variable 'M' [-Wunused-variable]
    8 |     ll N,M,i,j,k;
      |          ^
stove.cpp:8:14: warning: unused variable 'j' [-Wunused-variable]
    8 |     ll N,M,i,j,k;
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 50 ms 2020 KB Output is correct
17 Correct 51 ms 2020 KB Output is correct
18 Correct 51 ms 2020 KB Output is correct
19 Correct 50 ms 2020 KB Output is correct
20 Correct 51 ms 2020 KB Output is correct
21 Correct 52 ms 2020 KB Output is correct
22 Correct 50 ms 2020 KB Output is correct
23 Correct 52 ms 2020 KB Output is correct
24 Correct 50 ms 2148 KB Output is correct