Submission #45125

#TimeUsernameProblemLanguageResultExecution timeMemory
45125PajarajaStove (JOI18_stove)C++17
100 / 100
36 ms10404 KiB
#include <bits/stdc++.h>
int t[100007],a[100007];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&t[i]);
	int al=t[n-1]+1-t[0];
	for(int i=0;i<n-1;i++) a[i]=t[i+1]-t[i]-1;
	std::sort(a,a+n-1,std::greater<int>() );
	for(int i=0;i<k-1;i++) al-=a[i];
	printf("%d",al);
}

Compilation message (stderr)

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",&n,&k);
  ~~~~~^~~~~~~~~~~~~~
stove.cpp:7:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<n;i++) scanf("%d",&t[i]);
                       ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...