| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1304537 | marzuq01 | Stove (JOI18_stove) | C++20 | 14 ms | 2376 KiB |
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define nl '\n'
#define debug(x) cout << #x << ": " << x << "\n";
const int mod = 1e9+7;
const int MOD = 998244353;
string yes = "YES";
string no = "NO";
// CODING SETTING :O
void freo(string name) {
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
void fastIO() {
ios::sync_with_stdio(0);
cin.tie(0);
}
// WRONG ANSWER ON TEST 2: ?_?
void inputer() {
// take the input ONLY:
lint n,l,r; cin >> n >> l >> r;
}
void outputer() {
//take the input
//output inputs...
//solve();
}
void tracker(int test_case, int wanted) {
if (wanted != test_case) inputer();
else outputer();
}
// GENERAL SHORTCUTS AND FUNCTIONS :D
template<typename T>
void vprint(const vector<T> &arr) {
for (auto i : arr) cout << i << " ";
cout << nl;
}
template<typename T, typename ABCDEF>
void aprint(T arr[],ABCDEF n) {
for (ABCDEF i = 0; i < n;i++) { cout << arr[i] << " "; }
cout << "\n";
}
template<typename T>
T expo(T a, T b) {
if (b == 0) return 1;
else if (b == 1) return a;
if (b % 2 == 0) return expo(a*a % mod,b/2) % mod;
else return (a*expo(a*a % mod, b/2) % mod) % mod;
}
template<typename T>
T gcd(T a, T b) {
if (a == 0) return b;
else return gcd(b%a,a);
}
// ============< DONT TOUCH CODES ABOVE >=============
int isprime[2000000];
vector<int> prime;
void thanos() {
for (int i = 0;i < 2000000;i++) isprime[i] = 1;
isprime[0] = isprime[1] = 0;
for (int j = 4; j < 2000000;j+=2) isprime[j] = 0;
for (int i = 3;i*i < 2000000;i+=2) {
for (int j = i*i; j < 2000000;j += i) isprime[j] = 0;
}
prime.pb(2);
for (int i = 3;i < 2000000;i+=2) if(isprime[i]) prime.pb(i);
}
// ============< DONT also TOUCH CODES ABOVE >=============
void init() {
//thanos();
}
void solve() {
lint n,k; cin >> n >> k;
vector<lint> arr(n);
for (lint i = 0; i < n;i++) cin >> arr[i];
if (k == n) {cout << n << nl; return;}
vector<lint> brr;
for (lint i = 1;i < n;i++) brr.pb(arr[i] - arr[i-1] - 1);
sort(brr.begin(),brr.end());
lint count = n;
k = n-k;
for (lint i = 0; i < k;i++) count += brr[i];
cout << count << nl;
}
int main()
{
//freo("div7");
fastIO();
long long int t=1;
//cin >> t;
init();
for (int aura = 0; aura < t; aura++) {
//cout << "-------\n";
//cout << "Case #" <<aura+1 << ":";
solve();
}
//wrong answer finder: XD
/*
if (t == 4) {
while(t--) solve();
} else {
for (int aura = 1; aura <= t;aura++) {
tracker(aura,1081);
}
}
*/
return 0;
}
컴파일 시 표준 에러 (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... | ||||
