제출 #112344

#제출 시각아이디문제언어결과실행 시간메모리
112344luciocfStove (JOI18_stove)C++14
100 / 100
23 ms2048 KiB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e5+10;

int a[maxn], d[maxn];

int main(void)
{
	int n, k;
	scanf("%d %d", &n, &k);

	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);

	for (int i = 2; i <= n; i++)
		d[i-1] = a[i]-a[i-1];

	sort(d+1, d+n);

	int ans = k;
	for (int i = 1; i <= n-k; i++)
		ans += d[i];

	printf("%d\n", ans);
}

컴파일 시 표준 에러 (stderr) 메시지

stove.cpp: In function 'int main()':
stove.cpp:12: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:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...