답안 #737267

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

using namespace std;
int main() {
	int n, m, ans, x, y, i, j;
	
	cin >> n >> m;
	
	int a[n + 2];
	ans = 0;
	vector < int > v;
	for ( i = 1; i <= n; i ++) {
		cin >> a[i];
		if ( i > 1) {
			v.push_back(a[i] - a[i - 1]);
		}
	}
	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:20:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for (i = v.size() - 1; i >= v.size() - (m - 1); i --) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~~
stove.cpp:5:17: warning: unused variable 'x' [-Wunused-variable]
    5 |  int n, m, ans, x, y, i, j;
      |                 ^
stove.cpp:5:20: warning: unused variable 'y' [-Wunused-variable]
    5 |  int n, m, ans, x, y, i, j;
      |                    ^
stove.cpp:5:26: warning: unused variable 'j' [-Wunused-variable]
    5 |  int n, m, ans, x, y, i, j;
      |                          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 1 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 1 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 1 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 1 ms 212 KB Output is correct
5 Runtime error 1 ms 340 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -