제출 #125620

#제출 시각아이디문제언어결과실행 시간메모리
125620gs14004Stove (JOI18_stove)C++17
100 / 100
27 ms1908 KiB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;

vector<int> v;

int main(){
	int n, k, p;
	scanf("%d %d %d",&n,&k,&p);
	for(int i=1; i<n; i++){
		int q;
		scanf("%d",&q);
		v.push_back(q - p - 1);
		p = q;
	}
	sort(v.begin(), v.end());
	int ans = n;
	for(int i=0; i<n-k; i++) ans += v[i];
	cout << ans << endl;
}

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

stove.cpp: In function 'int main()':
stove.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n,&k,&p);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
stove.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&q);
   ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...