제출 #42265

#제출 시각아이디문제언어결과실행 시간메모리
42265RezwanArefin01Stove (JOI18_stove)C++14
50 / 100
3 ms648 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii; 

int a[5001], n, k, dp[5001][5001];

int main(int argc, char const *argv[]) {
	scanf("%d %d", &n, &k);
	vector<int> v; 
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if(i > 1) v.push_back(a[i - 1] - a[i]);
	}
	sort(v.begin(), v.end());
	int ans = a[n] - a[1] + k;
	for(int i = 0; i < k - 1; i++) ans += v[i];
 	cout << ans << endl;
}

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

stove.cpp: In function 'int main(int, const char**)':
stove.cpp:10:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &k);
                        ^
stove.cpp:13:21: 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...