| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1305977 | limon4ick | Stove (JOI18_stove) | C++20 | 13 ms | 1212 KiB |
/*#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#pragma ("reroll") */
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
#define ins insert
#define F first
#define S second
const int mod = 1e7 + 7,N = 5010,inf = 1e18;
signed main(){
//freopen("snnfsn.in","r",stdin)
//freopen("snnfsn.out","w",stdout)
std::ios::sync_with_stdio(false);
cin.tie(0);
int n,k;
cin >> n >> k;
int a[n + 1];
for(int i = 1;i<=n;i++) cin >> a[i];
int b[n + 1]{};
for(int i = 1;i<n;i++){
b[i] = (a[i + 1]) - a[i] - 1;
}
long long ans = n;
sort(b + 1,b + n);
for(int i = 1;i<=n-k;i++){
if(b[i]>0) ans+=b[i];
}
cout << ans;
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
