답안 #41075

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41075 2018-02-12T12:18:36 Z zscoder Stove (JOI18_stove) C++14
100 / 100
26 ms 2408 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll a[111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	vector<ll> d;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(i>0) d.pb(a[i]-a[i-1]);
	}
	ll ans = a[n-1]-a[0]+k;
	sort(d.rbegin(),d.rend());
	for(int i=0;i<k-1;i++)
	{
		ans-=d[i];
	}
	cout<<ans<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 1 ms 484 KB Output is correct
3 Correct 1 ms 560 KB Output is correct
4 Correct 1 ms 560 KB Output is correct
5 Correct 1 ms 560 KB Output is correct
6 Correct 1 ms 560 KB Output is correct
7 Correct 1 ms 560 KB Output is correct
8 Correct 1 ms 584 KB Output is correct
9 Correct 1 ms 608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 1 ms 484 KB Output is correct
3 Correct 1 ms 560 KB Output is correct
4 Correct 1 ms 560 KB Output is correct
5 Correct 1 ms 560 KB Output is correct
6 Correct 1 ms 560 KB Output is correct
7 Correct 1 ms 560 KB Output is correct
8 Correct 1 ms 584 KB Output is correct
9 Correct 1 ms 608 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 608 KB Output is correct
12 Correct 3 ms 608 KB Output is correct
13 Correct 2 ms 632 KB Output is correct
14 Correct 2 ms 632 KB Output is correct
15 Correct 2 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 1 ms 484 KB Output is correct
3 Correct 1 ms 560 KB Output is correct
4 Correct 1 ms 560 KB Output is correct
5 Correct 1 ms 560 KB Output is correct
6 Correct 1 ms 560 KB Output is correct
7 Correct 1 ms 560 KB Output is correct
8 Correct 1 ms 584 KB Output is correct
9 Correct 1 ms 608 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
11 Correct 2 ms 608 KB Output is correct
12 Correct 3 ms 608 KB Output is correct
13 Correct 2 ms 632 KB Output is correct
14 Correct 2 ms 632 KB Output is correct
15 Correct 2 ms 632 KB Output is correct
16 Correct 22 ms 2272 KB Output is correct
17 Correct 22 ms 2272 KB Output is correct
18 Correct 22 ms 2272 KB Output is correct
19 Correct 26 ms 2272 KB Output is correct
20 Correct 25 ms 2272 KB Output is correct
21 Correct 25 ms 2408 KB Output is correct
22 Correct 22 ms 2408 KB Output is correct
23 Correct 22 ms 2408 KB Output is correct
24 Correct 22 ms 2408 KB Output is correct