제출 #134152

#제출 시각아이디문제언어결과실행 시간메모리
134152BoxworldStove (JOI18_stove)C++14
0 / 100
2 ms256 KiB
#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);
}

컴파일 시 표준 에러 (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%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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...