# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
956138 | manishjha91 | Stove (JOI18_stove) | C++17 | 20 ms | 3364 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using lld = long double;
// #ifndef ONLINE_JUDGE
// #include "E:\Personal\cpp_codes\debugalgo.h"
// #else
// #define debug(x)
// #endif
//
void solve(int tc)
{
ll n,k;
cin>>n>>k;
vector<ll> a(n);
for(int i=0; i<n; i++)
{
cin>>a[i];
}
sort(a.begin(),a.end());
vector<ll> gap;
for(int i=1; i<n; i++)
{
gap.push_back(a[i]-a[i-1]-1);
}
ll res = n;
ll req = n;
sort(gap.begin(),gap.end());
for(int i=0; i<n-k; i++)
{
res+=gap[i];
}
cout<<res<<"\n";
}
int main()
{
ios_base:: sync_with_stdio(0);
cin.tie(0);
// #ifndef ONLINE_JUDGE
// freopen("Error.txt", "w", stderr);
// #endif
int tt = 1;
// cin >> tt;
for(int tc=1; tc<=tt; tc++)
{
solve(tc);
}
}
컴파일 시 표준 에러 (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... |