Submission #1114345

# Submission time Handle Problem Language Result Execution time Memory
1114345 2024-11-18T15:59:12 Z vjudge1 Bigger segments (IZhO19_segments) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    int n; cin >> n;
    vector<int> a(n + 1), pref(n + 1);
    for (int i = 1;  i<= n; i++){
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    vector<vector<int>> dp(n + 1, vector<int> (n + 1, 1e18));
    dp[0][0] = 0;
    int last = 0;
    for (int i = 1; i <= n; i++){
        
           for (int k = 0; k < i; k++){
               int suma = pref[i] - pref[k];
               if (suma >= dp[k][last]){
                   dp[i][last + 1] = min(dp[i][last + 1], suma);
               }
           }
        if (dp[i][last + 1] != 1e18) last++;
    }
    
    /*for (int i = 0; i <= n; i++){
        for (int j = 0; j <= n; j++){
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    }*/
   cout << last << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -