Submission #737269

# Submission time Handle Problem Language Result Execution time Memory
737269 2023-05-07T03:41:21 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]);
		}
	}
	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: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   20 |  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;
      |                                ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 -