답안 #1096740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1096740 2024-10-05T05:14:17 Z stdfloat Bigger segments (IZhO19_segments) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define ff  first
#define ss  second
#define pii pair<int, int>

#define all(v) (v).begin(), (v).end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	int n;
	cin >> n;

	vector<int> a(n);
	for (auto &i : a)
		cin >> i;

	vector<pii> dp[n];
	for (int i = 0; i < n; i++) {
		ll sm = 0;
		vector<pii> v;
		for (int j = i; j >= 0; j--) {
			sm += a[j];

			if (!j) v.push_back({sm, 1});
			else if (dp[j - 1][0].ff <= sm) v.push_back({sm, (*--upper_bound(all(dp[j - 1]), (pii){sm, LLONG_MAX})).ss + 1});
		}

		sort(v.begin(), v.end());

		int mx = 0;
		for (auto j : v) {
			mx = max(mx, j.ss);
			dp[i].push_back({j.ff, mx});
		}
	}

	cout << dp[n - 1].back().ss;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -