Submission #134152

# Submission time Handle Problem Language Result Execution time Memory
134152 2019-07-22T07:26:22 Z Boxworld Stove (JOI18_stove) C++14
0 / 100
2 ms 256 KB
#include <bits/stdc++.h>
using namespace std;
int d[100100];
int main(){
	int n,k,l,x,ans;
	scanf("%d%d%d",&n,&k,&l);
	for (int i=0;i<n-1;i++){
		scanf("%d",&x);
		d[i]=x-l-1;
		l=x;
	}
	sort(d,d+n-1);
	for (int i=0;i<n-k;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);
   ~~~~~^~~~~~~~~
stove.cpp:14:8: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
  printf("%d\n",n+ans);
  ~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -