# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
974577 |
2024-05-03T13:25:27 Z |
FIFI_cpp |
Stove (JOI18_stove) |
C++17 |
|
37 ms |
2300 KB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <fstream>
#include <iterator>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <cctype>
#include <string>
#include <cassert>
#include <set>
#include <bitset>
#include <unordered_set>
using ll = long long;
#define pb push_back
#define all(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// xcode cant include bits/stdc++.h
using namespace std;
//ifstream fin ("fenceplan.in");
//ofstream fout ("fenceplan.out");
/* /\_/\
* (= ._.)
* / > \>
*/
// encouraging cat
const ll INF = 100000000000000;
const ll mod = 1000000007;
int main()
{
int n,k;
cin >> n >> k;
vector<int> nums(n,0);
for (int i = 0;i < n;i++)
cin >> nums[i];
vector<int> intervals(n - 1,0);
for (int i = 1;i < n;i++)
{
intervals[i - 1] = (nums[i] - (nums[i - 1] + 1));
}
sort(all(intervals));
int cost = n;
for (int i = 0;i < n - k;i++)
{
cost += intervals[i];
}
cout << cost << '\n';
return 0;
}
Compilation message
stove.cpp:30:9: warning: "/*" within comment [-Wcomment]
30 | /* /\_/\
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
452 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
452 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
480 KB |
Output is correct |
16 |
Correct |
35 ms |
2208 KB |
Output is correct |
17 |
Correct |
37 ms |
2120 KB |
Output is correct |
18 |
Correct |
34 ms |
2300 KB |
Output is correct |
19 |
Correct |
34 ms |
2136 KB |
Output is correct |
20 |
Correct |
33 ms |
1972 KB |
Output is correct |
21 |
Correct |
34 ms |
2052 KB |
Output is correct |
22 |
Correct |
34 ms |
2028 KB |
Output is correct |
23 |
Correct |
37 ms |
2136 KB |
Output is correct |
24 |
Correct |
35 ms |
2128 KB |
Output is correct |