제출 #771755

#제출 시각아이디문제언어결과실행 시간메모리
771755JomnoiBigger segments (IZhO19_segments)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; const int MAX_N = 5e5 + 5; long long A[MAX_N], pos[MAX_N], dp[MAX_N]; int main() { cin.tie(nullptr)->sync_with_stdio(false); int N; cin >> N; for (int i = 1; i <= N; i++) { cin >> A[i]; A[i] += A[i - 1]; } for (int i = 1; i <= N; i++) { pos[i] = max(pos[i - 1], pos[i]); dp[i] = dp[pos[i]] + 1; int l = i, r = N; while (l < r) { int mid = (l + r) / 2; if (A[mid] - A[i] >= A[i] - A[pos[i]]) r = mid; else l = mid + 1; } pos[l] = i; } cout << dp[N]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...