# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
157772 | 2019-10-12T21:30:19 Z | ZwariowanyMarcin | Stove (JOI18_stove) | C++14 | 82 ms | 6492 KB |
#pragma GCC optimize("O3") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define mp make_pair #define pb push_back #define ld long double #define ss(x) (int) x.size() #define FOR(i, j, n) for(int i = j; i <= n; ++i) #define fi first #define se second #define cat(x) cerr << #x << " = " << x << endl; #define ios cin.tie(0); ios_base::sync_with_stdio(0) using namespace std; const int nax = 1e5 + 11; int n, k; ll sum; int a[nax]; multiset <int> secik; int main() { scanf("%d %d", &n, &k); sum = n; k = n - k; FOR(i, 1, n) { scanf("%d", &a[i]); if(i > 1) secik.insert(a[i] - a[i - 1] - 1); } while(k--) { sum += *secik.begin(); secik.erase(secik.begin()); } printf("%lld\n", sum); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 4 ms | 504 KB | Output is correct |
11 | Correct | 4 ms | 504 KB | Output is correct |
12 | Correct | 6 ms | 508 KB | Output is correct |
13 | Correct | 3 ms | 504 KB | Output is correct |
14 | Correct | 3 ms | 504 KB | Output is correct |
15 | Correct | 3 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 4 ms | 504 KB | Output is correct |
11 | Correct | 4 ms | 504 KB | Output is correct |
12 | Correct | 6 ms | 508 KB | Output is correct |
13 | Correct | 3 ms | 504 KB | Output is correct |
14 | Correct | 3 ms | 504 KB | Output is correct |
15 | Correct | 3 ms | 504 KB | Output is correct |
16 | Correct | 72 ms | 6348 KB | Output is correct |
17 | Correct | 73 ms | 6428 KB | Output is correct |
18 | Correct | 71 ms | 6392 KB | Output is correct |
19 | Correct | 71 ms | 6364 KB | Output is correct |
20 | Correct | 72 ms | 6392 KB | Output is correct |
21 | Correct | 82 ms | 6492 KB | Output is correct |
22 | Correct | 67 ms | 6392 KB | Output is correct |
23 | Correct | 67 ms | 6392 KB | Output is correct |
24 | Correct | 65 ms | 6392 KB | Output is correct |