Submission #503115

#TimeUsernameProblemLanguageResultExecution timeMemory
503115stanislavpolynBigger segments (IZhO19_segments)C++17
27 / 100
1567 ms35660 KiB
#include <bits/stdc++.h> #define fr(i, a, b) for(int i = (a); i <= (b); ++i) #define rf(i, a, b) for(int i = (a); i >= (b); --i) #define fe(x, y) for(auto& x : y) #define fi first #define se second #define pb push_back #define mp make_pair #define mt make_tuple #define all(x) (x).begin(), (x).end() #define pw(x) (1LL << (x)) #define sz(x) (int)(x).size() using namespace std; mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define fbo find_by_order #define ook order_of_key template<typename T> bool umn(T& a, T b) { return (a > b ? (a = b, 1) : 0); } template<typename T> bool umx(T& a, T b) { return (a < b ? (a = b, 1) : 0); } using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; template<typename T> using ve = vector<T>; const int N = 3e3 + 5; int n; int a[N]; ll pref[N]; int dp[N][N]; int brute() { fr(i, 0, n) { fr(j, 0, n) { dp[i][j] = -1e9; } } fr(i, 1, n) { dp[i][1] = 1; fr(j, 1, i) { fr(nxt, i + 1, n) { if(pref[nxt] - pref[i] >= pref[i] - pref[j - 1]) { umx(dp[nxt][i + 1], dp[i][j] + 1); } } } } int mx = 0; fr(i, 1, n) { fr(j, 1, n) { umx(mx, dp[i][j]); } } return mx; } int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); #else // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); #endif cin >> n; fr(i, 1, n) { cin >> a[i]; pref[i] = a[i] + pref[i - 1]; } cout << brute() << "\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...