Submission #1018736

# Submission time Handle Problem Language Result Execution time Memory
1018736 2024-07-10T09:06:08 Z vjudge1 Parkovi (COCI22_parkovi) C++17
0 / 110
129 ms 6224 KB
#include <bits/stdc++.h>
using namespace std;

#define int int64_t

int n, k;

vector<bool> ans;
bool f(vector<int> const& a, int m) {
	int curk = 1, cur = 0;
	bool flag = true;
	ans[0] = false;
	for(int i = 1; i < n; i ++) {
		if(a[i] - cur > m) {
			if(flag) {
				cur = a[i - 1];
				flag = false;
				ans[i - 1] = true;
				if(a[i] - a[i - 1] > m) {
					flag = true;
					cur = a[i];
					curk++;
				}
			}
			else {
				flag = true;
				cur = a[i];
				curk ++;
			}
		}
		ans[i] = false;
	}
	if(flag) ans[n - 1] = true;
	return curk <= k;
}

int32_t main() {
	cin >> n >> k;
	vector<int> a(n, 0);
	ans.assign(n, false);
	for(int i = 1; i < n; i ++) {
		int d, b, c;
		cin >> d >> b >> c;
		a[i] = c;
	}
	for(int i = 1; i < n; i ++) a[i] += a[i-1];
	int l = 1, r = 1e18;
	while(r - l > 1) {
		int m = (l + r) >> 1;
		bool cur = f(a, m);
		if(cur) r = m;
		else l = m + 1;
	}
	cout << r << '\n';
	for(int i = 0; i < n; i ++) if(ans[i]) cout << i + 1 << ' ';
	cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 4696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 129 ms 6224 KB Output is correct
2 Correct 128 ms 5904 KB Output is correct
3 Incorrect 129 ms 5864 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -