Submission #909947

# Submission time Handle Problem Language Result Execution time Memory
909947 2024-01-17T16:16:15 Z raphaelp Stove (JOI18_stove) C++14
100 / 100
49 ms 2688 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, K;
    cin >> N >> K;
    K--;
    vector<int> Tab(N);
    for (int i = 0; i < N; i++)
    {
        cin >> Tab[i];
    }
    sort(Tab.begin(), Tab.end());
    vector<int> dif;
    for (int i = 1; i < N; i++)
    {
        dif.push_back(Tab[i] - Tab[i - 1]);
    }
    sort(dif.begin(), dif.end());
    int tot = 1;
    for (int i = 0; i < N - 1; i++)
    {
        if (i < N - 1 - K)
            tot += dif[i];
        else
            tot += 1;
    }
    cout << tot;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 36 ms 2336 KB Output is correct
17 Correct 35 ms 2264 KB Output is correct
18 Correct 36 ms 2256 KB Output is correct
19 Correct 48 ms 2256 KB Output is correct
20 Correct 35 ms 2256 KB Output is correct
21 Correct 49 ms 2344 KB Output is correct
22 Correct 44 ms 2264 KB Output is correct
23 Correct 35 ms 2688 KB Output is correct
24 Correct 35 ms 2216 KB Output is correct