답안 #66728

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66728 2018-08-12T07:41:27 Z ege_eksi Stove (JOI18_stove) C++14
100 / 100
37 ms 1524 KB
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<queue>

using namespace std;

int main()
{
	int n , k;
	scanf("%d %d",&n,&k);
	
	int *a = new int[n];
	
	scanf("%d",&a[0]);
	
	priority_queue<int> pq;
	
	for(int i = 1 ; i < n ; i++)
	{
		scanf("%d",&a[i]);
		
		pq.push(a[i] -(a[i-1]+1));
	}
	
	int ans = (a[n-1]+1) - a[0];
	
	while(k > 1)
	{
		ans -= pq.top();
		pq.pop();
		
		k--;
	}
	
	printf("%d",ans);
	
	return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:11: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:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&a[0]);
  ~~~~~^~~~~~~~~~~~
stove.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 356 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 3 ms 560 KB Output is correct
8 Correct 3 ms 564 KB Output is correct
9 Correct 2 ms 564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 356 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 3 ms 560 KB Output is correct
8 Correct 3 ms 564 KB Output is correct
9 Correct 2 ms 564 KB Output is correct
10 Correct 4 ms 568 KB Output is correct
11 Correct 4 ms 612 KB Output is correct
12 Correct 3 ms 612 KB Output is correct
13 Correct 4 ms 740 KB Output is correct
14 Correct 3 ms 740 KB Output is correct
15 Correct 4 ms 740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 356 KB Output is correct
4 Correct 2 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 3 ms 560 KB Output is correct
8 Correct 3 ms 564 KB Output is correct
9 Correct 2 ms 564 KB Output is correct
10 Correct 4 ms 568 KB Output is correct
11 Correct 4 ms 612 KB Output is correct
12 Correct 3 ms 612 KB Output is correct
13 Correct 4 ms 740 KB Output is correct
14 Correct 3 ms 740 KB Output is correct
15 Correct 4 ms 740 KB Output is correct
16 Correct 28 ms 1524 KB Output is correct
17 Correct 25 ms 1524 KB Output is correct
18 Correct 26 ms 1524 KB Output is correct
19 Correct 24 ms 1524 KB Output is correct
20 Correct 28 ms 1524 KB Output is correct
21 Correct 35 ms 1524 KB Output is correct
22 Correct 34 ms 1524 KB Output is correct
23 Correct 35 ms 1524 KB Output is correct
24 Correct 37 ms 1524 KB Output is correct