# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
307177 | 2020-09-27T09:24:24 Z | radaiosm7 | Stove (JOI18_stove) | C++ | 53 ms | 7152 KB |
#include <bits/stdc++.h> using namespace std; int n, k, i, a, b, ans; vector<pair<int,int>> ranges; unordered_set<int> check; vector<int> diff; int main() { //freopen("test.in", "r", stdin); scanf("%d %d", &n, &k); check.rehash(n); ans = n; k--; for (i=0; i < n; i++) { scanf("%d", &a); check.insert(a); if (check.find(a-1) != check.end()) { ranges[ranges.size()-1].second = a+1; } else { ranges.push_back(make_pair(a, a+1)); } } for (i=1; i < ranges.size(); i++) { diff.push_back(ranges[i].first - ranges[i-1].second); } k = diff.size() - k; sort(diff.begin(), diff.end()); for (i=0; i < k; i++) { ans += diff[i]; } printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 372 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 372 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 372 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 372 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 512 KB | Output is correct |
11 | Correct | 2 ms | 512 KB | Output is correct |
12 | Correct | 2 ms | 512 KB | Output is correct |
13 | Correct | 2 ms | 512 KB | Output is correct |
14 | Correct | 2 ms | 512 KB | Output is correct |
15 | Correct | 2 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 372 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 372 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 512 KB | Output is correct |
11 | Correct | 2 ms | 512 KB | Output is correct |
12 | Correct | 2 ms | 512 KB | Output is correct |
13 | Correct | 2 ms | 512 KB | Output is correct |
14 | Correct | 2 ms | 512 KB | Output is correct |
15 | Correct | 2 ms | 512 KB | Output is correct |
16 | Correct | 50 ms | 6892 KB | Output is correct |
17 | Correct | 49 ms | 6892 KB | Output is correct |
18 | Correct | 48 ms | 6944 KB | Output is correct |
19 | Correct | 49 ms | 6892 KB | Output is correct |
20 | Correct | 51 ms | 7152 KB | Output is correct |
21 | Correct | 50 ms | 6892 KB | Output is correct |
22 | Correct | 53 ms | 7024 KB | Output is correct |
23 | Correct | 48 ms | 6892 KB | Output is correct |
24 | Correct | 48 ms | 6892 KB | Output is correct |