이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <chrono>
#define unint unsigned int
#define sint signed int
#define shint short int
#define usint unsigned short int
#define lint long int
#define ulint unsigned long int
#define ll long long
#define ull unsigned long long
#define ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf 1e15
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define all(a) a.begin(),a.end()
#define rall(a) a.begin(),a.end(),greater<int>()
using namespace std;
using namespace std::chrono;
/*auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
vector<char> abecede = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
cout << "Time taken by function: " << duration.count() << " microseconds" << endl;*/
void solve(){
}
#define maxn 100005
int a[maxn];
bool cmp(pair<int,int> a,pair<int,int> b){
return a.fi-a.sc>b.fi-b.sc;
}
int main(){
int n,k;
cin >> n>>k;
for(int i = 0;i<n;i++) cin >> a[i];
sort(a,a+n,greater<int>());
vector<pair<int,int> > v;
int ans = n;
for(int i = 0;i<n-1;i++){
v.pb({a[i+1]+1,a[i]});
}
sort(v.begin(),v.end(),cmp);
//for(auto &it : v) cout<<it.fi<< " "<<it.sc<<"\n";
for(int i=0;i<n-k;i++){
ans+=v[i].sc-v[i].fi;
}
cout<<ans;
}
컴파일 시 표준 에러 (stderr) 메시지
stove.cpp:11:9: warning: ISO C++11 requires whitespace after the macro name
11 | #define ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
| ^~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |