답안 #737270

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
737270 2023-05-07T03:42:30 Z Amaarsaa Stove (JOI18_stove) C++14
0 / 100
1 ms 340 KB
#include<bits/stdc++.h>

using namespace std;
int main() {
	long long n, m, ans, x, y, i, j;
	
	cin >> n >> m;
	
	long long a[n + 2];
	ans = 0;
	vector < long long > v;
	for ( i = 1; i <= n; i ++) {
		cin >> a[i];
		if ( i > 1) {
			v.push_back(a[i] - a[i - 1]);
		}
	}
	m= min(n , m);
	ans = a[n] - a[1] + 1;
	sort (v.begin(), v.end());
	for (i = v.size() - 1; i >= v.size() - (m - 1); i --) {
		ans -= (v[i] - 1);
	}
	cout << ans << endl;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:21:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   21 |  for (i = v.size() - 1; i >= v.size() - (m - 1); i --) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~~
stove.cpp:5:23: warning: unused variable 'x' [-Wunused-variable]
    5 |  long long n, m, ans, x, y, i, j;
      |                       ^
stove.cpp:5:26: warning: unused variable 'y' [-Wunused-variable]
    5 |  long long n, m, ans, x, y, i, j;
      |                          ^
stove.cpp:5:32: warning: unused variable 'j' [-Wunused-variable]
    5 |  long long n, m, ans, x, y, i, j;
      |                                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Runtime error 1 ms 340 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Runtime error 1 ms 340 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Runtime error 1 ms 340 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -