# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1102464 | 2024-10-18T07:38:11 Z | sktodow | Stove (JOI18_stove) | C++17 | 18 ms | 3164 KB |
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define int long long #define pb push_back #define mid a+(b-a)/2 const int N=5e5+5; const int MOD=1e9+7; const int inf=2e18+5; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; void io(string name = ""){ freopen((name+".in").c_str(), "r", stdin); freopen((name+".out").c_str(), "w", stdout); } int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n,k; cin>>n>>k; vector<int>arr(n); for(auto &a:arr){cin>>a;} sort(arr.begin(),arr.end()); vector<int>dis; for(int i=1;i<n;i++){ dis.pb(arr[i]-arr[i-1]-1); } sort(dis.rbegin(),dis.rend()); int ans=0; for(int i=0;i<min(k-1,(int)dis.size());i++){ ans+=dis[i]; } cout<<arr[n-1]-arr[0]+1-ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 504 KB | Output is correct |
6 | Correct | 0 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 0 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 504 KB | Output is correct |
6 | Correct | 0 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 0 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 504 KB | Output is correct |
6 | Correct | 0 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 0 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
13 | Correct | 1 ms | 336 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 17 ms | 3164 KB | Output is correct |
17 | Correct | 17 ms | 3024 KB | Output is correct |
18 | Correct | 17 ms | 3020 KB | Output is correct |
19 | Correct | 17 ms | 3024 KB | Output is correct |
20 | Correct | 18 ms | 3024 KB | Output is correct |
21 | Correct | 17 ms | 3132 KB | Output is correct |
22 | Correct | 18 ms | 3024 KB | Output is correct |
23 | Correct | 18 ms | 3024 KB | Output is correct |
24 | Correct | 18 ms | 3040 KB | Output is correct |