# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1192802 | cbnhtmanh | Stove (JOI18_stove) | C++20 | 16 ms | 1480 KiB |
/*
.=#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#=.
.*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+
:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
=%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
.+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%=
.*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%:
:#%%%%%%%%%#=....-#:......-*%%*:......:**+++++++++++++#%%%#++++++++++++++%*+++++++++++++++%%%%%%#.
-%%%%%%%%+:......+%#-.....:+#-......:*%#+++++++++++++++*%%*+++++++++++++*%+++++++++++++++*%%%%%%*.
.=%%%%%%-.........#%%%-...+#-.......+%%%#+++++#####*+++++#%++++++########%%####*+++++#####%%%%%%%=.
.*%%%%%%:........-%%%%%+-#=.......=%%%%%*+++++%%%%%#+++++%#+++++#%%%%%%%%%%%%%%++++++%%%%%%%%%%%%-.
:#%%%%%%--*+.....+%%%%%%+........#%%%%%%++++++++++++++++%%*++++++++++++#%%%%%%%+++++*%%%%%%%%%%%#:
.:%%%%%%%%%%=....:#%%%%+...........*%%%%#++++++++++++++++#%+++++++++++++#%%%%%%*+++++%%%%%%%%%%%%*:
.-%%%%%%%%%#:....-%%%*..............=%%%++++++%%%%%%*++++**+++++#%%%%%%%%%%%%%%++++++%%%%%%%%%%%%+.
.+%%%%%%%%%*.....+%#:......:*-.......=%#+++++*#####*+++++#*+++++########%%%%%%#+++++#%%%%%%%%%%%%=.
.*%%%%%%%%%=....:+-.......+%%%+.......-#*+++++++++++++++##++++++++++++++*%%%%%*+++++%%%%%%%%%%%%%-
.%%%%%%%%%%:............+%%%%%%#=.......#*+++++++++++*#%%#++++++++++++++#%%%%%*++++*%%%%%%%%%%%%#-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#:
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*.
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*.
.=#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#=.
*/
#include <bits/stdc++.h>
#define fi(i, a, b) for( int i = a; i <= b; i++ )
#define fid(i, a, b) for( int i = a; i >= b; i-- )
#define getbit(x, i) ((x>>i)&1)
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define st first
#define nd second
#define mp make_pair
#define HTManh ""
#define maxn 100009
#define endl '\n'
using namespace std;
int test;
int n, k;
int a[100009];
priority_queue<int> pq;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL); cout.tie(NULL);
if (fopen(HTManh".inp", "r"))
{
freopen(HTManh".inp", "r", stdin);
freopen(HTManh".out", "w", stdout);
}
cin >> n >> k;
fi(i,1,n) cin >> a[i];
ll res = a[n]+1-a[1];
fi(i,1,n-1)
{
//cout << a[i+1]-a[i]-1 << endl;
pq.push(a[i+1]-a[i]-1);
}
fi(i,1,k-1)
{
res -= pq.top();
pq.pop();
}
cout << res << endl;
}
컴파일 시 표준 에러 (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... |