| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1286287 | LilPluton | Stove (JOI18_stove) | C++20 | 1096 ms | 332 KiB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
const int inf = 12345;
const int mod = 998244353;
void opd(){
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
}
struct BIT{
int n;
vector<int> ft;
void init(int N){
n = N;
ft.assign(n + 1, 0);
}
void add(int pos, int val){
while (pos <= n)
{
ft[pos] += val;
pos += pos & -pos;
}
}
int get(int pos){
int res = 0;
while (pos > 0)
{
res += ft[pos];
pos -= pos & -pos;
}
return res;
}
};
struct DSU
{
vector<int>par, siz;
int n;
DSU(int N)
{
n = N + 5;
par.resize(n + 1, 0);
siz.assign(n + 1, 1);
for(int i = 0; i <= n; ++i)
par[i] = i;
}
int _find(int v)
{
if(par[v] == v)
return v;
return par[v] = _find(par[v]);
}
bool unite(int a, int b)
{
a = _find(a);
b = _find(b);
if(a != b)
{
if(siz[a] < siz[b])
swap(a, b);
siz[a] += siz[b];
par[b] = a;
return 1;
}
return 0;
}
};
const int md = 1e9 + 7;
void solve(){
int n, k;
cin>>n>>k;
int a[n+1];
a[0]=-md;
multiset<int>st;
for(int i=1;i<=n;++i){
cin>>a[i];
st.insert(a[i]-a[i-1]);
}
int res=k;
n-=k;
while(n--){
res+=*st.begin();
st.erase(st.begin());
}
cout<<res<<endl;
}
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
//opd();
int T = 1;
cin>>T;
while(T--){
solve();
}
}
컴파일 시 표준 에러 (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... | ||||
