Submission #134172

# Submission time Handle Problem Language Result Execution time Memory
134172 2019-07-22T07:46:23 Z Boxworld Stove (JOI18_stove) C++14
100 / 100
28 ms 1784 KB
#include <bits/stdc++.h>
using namespace std;
int d[100100];
int main(){
	int n,k,l,x,ans=0,tmp=0;
	scanf("%d%d%d",&n,&k,&l);
	for (int i=0;i<n-1;i++){
		scanf("%d",&x);
		d[tmp]=x-l-1;
		if (d[tmp]!=0)tmp++;
		l=x;
	}
	sort(d,d+tmp);
	for (int i=0;i<max(0,tmp-k+1);i++)ans+=d[i];
	printf("%d\n",n+ans);
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&k,&l);
  ~~~~~^~~~~~~~~~~~~~~~~~~
stove.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&x);
   ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 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 504 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
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 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 504 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 1784 KB Output is correct
17 Correct 28 ms 1744 KB Output is correct
18 Correct 27 ms 1656 KB Output is correct
19 Correct 27 ms 1704 KB Output is correct
20 Correct 27 ms 1656 KB Output is correct
21 Correct 27 ms 1656 KB Output is correct
22 Correct 28 ms 1784 KB Output is correct
23 Correct 28 ms 1688 KB Output is correct
24 Correct 27 ms 1720 KB Output is correct