Submission #162887

# Submission time Handle Problem Language Result Execution time Memory
162887 2019-11-10T07:47:22 Z abacaba Bigger segments (IZhO19_segments) C++14
0 / 100
2 ms 376 KB
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define int long long

const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 5e5 + 15;
int n, m, a[N], p[N], maxp[N], dp[N];

main() {
    ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        p[i] = p[i-1] + a[i];
        maxp[i] = max(maxp[i-1], p[i]);
    }
    for(int i = 1; i <= n; ++i) {
        int l = 1, r = i - 1;
        dp[i] = 1;
        for(int f = 0; f < i; ++f)
            for(int l = f + 1; l < i; ++l)
                if(2 * p[l] - p[f] <= p[i])
                    dp[i] = max(dp[i], dp[l] + 1);
    }
    cout << dp[n] << endl;
    return 0;
}

Compilation message

segments.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
segments.cpp: In function 'int main()':
segments.cpp:38:13: warning: unused variable 'l' [-Wunused-variable]
         int l = 1, r = i - 1;
             ^
segments.cpp:38:20: warning: unused variable 'r' [-Wunused-variable]
         int l = 1, r = i - 1;
                    ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -