답안 #704218

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
704218 2023-03-02T00:53:59 Z alanl Stove (JOI18_stove) C++14
100 / 100
22 ms 3156 KB
#include <bits/stdc++.h>
#include <queue>
#define pb push_back
#define F first
#define S second
#define rep(X, a,b) for(int X=a;X<b;++X)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (int)(a).size()
#define NL "\n"
using namespace std;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;
typedef long long ll;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << "," << p.second << ')'; }
template<typename A> ostream& operator<<(ostream &os, const vector<A> &p){
	for(const auto &a:p)
		os << a << " ";
	os << "\n";
	return os;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n, k;
	cin>>n>>k;
	vector<ll> te(n);
	rep(i,0,n) cin>>te[i];
	ll ans=n;
	priority_queue<ll, vector<ll>, greater<ll>> pq;
	rep(i,1,n){
		pq.push(te[i]-te[i-1]);
	}
	while(n>k){
		ans+=pq.top()-1;
		pq.pop();
		n--;
	}
	cout<<ans<<NL;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 376 KB Output is correct
16 Correct 22 ms 3148 KB Output is correct
17 Correct 22 ms 3144 KB Output is correct
18 Correct 22 ms 3144 KB Output is correct
19 Correct 21 ms 3156 KB Output is correct
20 Correct 18 ms 3144 KB Output is correct
21 Correct 13 ms 3140 KB Output is correct
22 Correct 13 ms 3156 KB Output is correct
23 Correct 12 ms 3148 KB Output is correct
24 Correct 12 ms 3152 KB Output is correct