답안 #209722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
209722 2020-03-15T12:10:53 Z gratus907 Stove (JOI18_stove) C++17
100 / 100
29 ms 3316 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
using pii = pair <int, int>;
#define int ll
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = false;

vector <int> allgap;
int T[101010];
int n, k;
int32_t main()
{
    usecppio
    cin >> n >> k;
    for (int i = 1; i<=n; i++) cin >> T[i];
    for (int i = 2; i<=n; i++)
        allgap.push_back(T[i]-T[i-1]-1);
    sort(all(allgap),greater<int>());
    int off = 0;
    for (int i = 0; i<k-1; i++)
        off += allgap[i];
    cout << T[n]-T[1]+1-off << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 380 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 504 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 380 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 504 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 28 ms 3316 KB Output is correct
17 Correct 29 ms 3188 KB Output is correct
18 Correct 28 ms 3188 KB Output is correct
19 Correct 29 ms 3188 KB Output is correct
20 Correct 28 ms 3188 KB Output is correct
21 Correct 28 ms 3188 KB Output is correct
22 Correct 29 ms 3188 KB Output is correct
23 Correct 28 ms 3192 KB Output is correct
24 Correct 27 ms 3188 KB Output is correct