Submission #404862

# Submission time Handle Problem Language Result Execution time Memory
404862 2021-05-15T07:48:39 Z ahmeteren Stove (JOI18_stove) C++14
0 / 100
3 ms 620 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
   		freopen("input.txt", "r", stdin);
   		freopen("output.txt", "w", stdout);
   	#endif
	int n, k, sil = 0;
	cin >> n >> k;
	vector<int> vec(n), a;
	for(int i = 0; i < n; i++)
	{
		cin >> vec[i];
		if(i > 0)
			a.push_back(vec[i] - vec[i-1] - 1);
	}
	sort(a.rbegin(), a.rend());
	for(int i = 0; i < k-1; i++)
	{
		sil += a[i];
	}
	cout << vec[n-1] + 1 - vec[0] - sil << endl;
	return 0;;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:6:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |      freopen("input.txt", "r", stdin);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:7:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |      freopen("output.txt", "w", stdout);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 620 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 620 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 620 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -