답안 #146927

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146927 2019-08-26T16:44:28 Z GodTe Stove (JOI18_stove) C++14
100 / 100
29 ms 1524 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;

// #define TT() printf("%.4f sec\n", (double) clock() / CLOCKS_PER_SEC )
#define Fi first
#define Se second
#define rep(i, n) for(ll i=0;i<n;i++)
#define repp(i, n) for(ll i=1;i<=n;i++)

#define INF 1987654321
#define IINF 987654321987654321

int n,k; vector<int> v,v1;

int main(){
	scanf("%d%d",&n,&k);
	repp(i,n){
		int x; scanf("%d",&x); v.push_back(x);
	}
	int ans = v[n-1]-v[0]+1;
	rep(i,n-1) v1.push_back(v[i+1]-v[i]-1);
	sort(v1.begin(),v1.end(),greater<int>());
	rep(i,min(n-1,k-1)) ans -= v1[i];
	printf("%d\n",ans);

	return 0;
} 

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~
stove.cpp:22:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x; scanf("%d",&x); v.push_back(x);
          ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 27 ms 1520 KB Output is correct
17 Correct 28 ms 1520 KB Output is correct
18 Correct 27 ms 1412 KB Output is correct
19 Correct 29 ms 1520 KB Output is correct
20 Correct 29 ms 1492 KB Output is correct
21 Correct 28 ms 1520 KB Output is correct
22 Correct 28 ms 1520 KB Output is correct
23 Correct 27 ms 1492 KB Output is correct
24 Correct 28 ms 1524 KB Output is correct