제출 #110076

#제출 시각아이디문제언어결과실행 시간메모리
110076maruiiStove (JOI18_stove)C++14
100 / 100
31 ms2176 KiB
#include<bits/stdc++.h>
using namespace std;
int N, K;
int A[100001], B[100001];
int main(){
	scanf("%d%d",&N,&K);
	for(int i=0; i<N; ++i)
		scanf("%d",A+i);
	for(int i=0; i<N-1; ++i)
		B[i] = A[i+1]-A[i];
	sort(B, B+N-1);
	int ans = accumulate(B, B+N-K, 0);
	printf("%d",ans+K);
}

컴파일 시 표준 에러 (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:8:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",A+i);
   ~~~~~^~~~~~~~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…