| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 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;
}컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
