Submission #863255

# Submission time Handle Problem Language Result Execution time Memory
863255 2023-10-20T00:16:17 Z maks007 Stove (JOI18_stove) C++14
20 / 100
1000 ms 360 KB
#include "bits/stdc++.h"

using namespace std;

#define int long long 

signed main () {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	vector <int> a(n);
	for(int i = 0; i < n; i ++) cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 1e9;
	for(int mask = 0; mask < (1 << n); mask ++) {
		if(__builtin_popcount(mask) != k) continue;
		if(mask % 2 != 1) continue;
		int prev = a[0], cnt = 0;
		for(int i = 1; i < n; i ++) {
			if(mask & (1 << i)) {
				cnt += a[i-1]+1-prev;
				prev = a[i];
			}
		}
		cnt += a[n-1]+1-prev;
		ans = min(ans, cnt);
	}
	cout << ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 356 KB Output is correct
6 Correct 0 ms 360 KB Output is correct
7 Correct 1 ms 352 KB Output is correct
8 Correct 9 ms 352 KB Output is correct
9 Correct 0 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 356 KB Output is correct
6 Correct 0 ms 360 KB Output is correct
7 Correct 1 ms 352 KB Output is correct
8 Correct 9 ms 352 KB Output is correct
9 Correct 0 ms 352 KB Output is correct
10 Execution timed out 1055 ms 348 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 356 KB Output is correct
6 Correct 0 ms 360 KB Output is correct
7 Correct 1 ms 352 KB Output is correct
8 Correct 9 ms 352 KB Output is correct
9 Correct 0 ms 352 KB Output is correct
10 Execution timed out 1055 ms 348 KB Time limit exceeded
11 Halted 0 ms 0 KB -