Submission #344635

# Submission time Handle Problem Language Result Execution time Memory
344635 2021-01-06T06:52:39 Z nevermoree Bigger segments (IZhO19_segments) C++17
27 / 100
1500 ms 12824 KB
#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define nl '\n'
#define pii pair <ll, ll>
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323846264
#define y1 abacaba
#define fn "abc"
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define pcnt(i) __builtin_popcount(i)
#define lcm(a,b) (a * b) / __gcd(a, b)
#define chill_wave ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pressF freopen("triangles.in", "r", stdin); freopen("triangles.out", "w", stdout);

using namespace std;

const long long MXN = 1e6 + 3;
const long long MAXN = 1e3 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long MAXLOG = 22;
const long long MAX = 32000;

inline void f_math(bool ok = 0) { chill_wave if(ok) { pressF; } }

//int dx[]= {1,0,-1,0}; int dy[]= {0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1}; int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2}; int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={-1,-1,+0,+1,+1,+0}; int dy[]={-1,+1,+2,+1,-1,-2}; //Hexagonal Direction

ll n, a[MXN], ans;

ll dp[MAXN][MAXN], pref[MXN];

int main() {

	f_math();

    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
        dp[1][i] = 1;
    }
    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j++) {
            for(int k = j + 1; k <= n; k++) {
                if(!dp[i][j]) continue;
                if(pref[k] - pref[j] >= pref[j] - pref[i - 1]) {
                    dp[j + 1][k] = max(dp[j + 1][k], dp[i][j] + 1);
                }
            }
        }
    }
    for(int i = 1; i <= n; i++) {
        ans = max(ans, dp[i][n]);
    }
    cout << ans;
    return 0;
}

Compilation message

segments.cpp: In function 'void f_math(bool)':
segments.cpp:20:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   20 | #define pressF freopen("triangles.in", "r", stdin); freopen("triangles.out", "w", stdout);
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
segments.cpp:31:55: note: in expansion of macro 'pressF'
   31 | inline void f_math(bool ok = 0) { chill_wave if(ok) { pressF; } }
      |                                                       ^~~~~~
segments.cpp:20:60: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   20 | #define pressF freopen("triangles.in", "r", stdin); freopen("triangles.out", "w", stdout);
      |                                                     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
segments.cpp:31:55: note: in expansion of macro 'pressF'
   31 | inline void f_math(bool ok = 0) { chill_wave if(ok) { pressF; } }
      |                                                       ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 22 ms 364 KB Output is correct
17 Correct 33 ms 2924 KB Output is correct
18 Correct 37 ms 3200 KB Output is correct
19 Correct 35 ms 2412 KB Output is correct
20 Correct 38 ms 3308 KB Output is correct
21 Correct 47 ms 3180 KB Output is correct
22 Correct 20 ms 2412 KB Output is correct
23 Correct 9 ms 1772 KB Output is correct
24 Correct 36 ms 3180 KB Output is correct
25 Correct 37 ms 3180 KB Output is correct
26 Correct 44 ms 3308 KB Output is correct
27 Correct 33 ms 2924 KB Output is correct
28 Correct 52 ms 3436 KB Output is correct
29 Correct 39 ms 3308 KB Output is correct
30 Correct 37 ms 3308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 22 ms 364 KB Output is correct
17 Correct 33 ms 2924 KB Output is correct
18 Correct 37 ms 3200 KB Output is correct
19 Correct 35 ms 2412 KB Output is correct
20 Correct 38 ms 3308 KB Output is correct
21 Correct 47 ms 3180 KB Output is correct
22 Correct 20 ms 2412 KB Output is correct
23 Correct 9 ms 1772 KB Output is correct
24 Correct 36 ms 3180 KB Output is correct
25 Correct 37 ms 3180 KB Output is correct
26 Correct 44 ms 3308 KB Output is correct
27 Correct 33 ms 2924 KB Output is correct
28 Correct 52 ms 3436 KB Output is correct
29 Correct 39 ms 3308 KB Output is correct
30 Correct 37 ms 3308 KB Output is correct
31 Execution timed out 1574 ms 12824 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 22 ms 364 KB Output is correct
17 Correct 33 ms 2924 KB Output is correct
18 Correct 37 ms 3200 KB Output is correct
19 Correct 35 ms 2412 KB Output is correct
20 Correct 38 ms 3308 KB Output is correct
21 Correct 47 ms 3180 KB Output is correct
22 Correct 20 ms 2412 KB Output is correct
23 Correct 9 ms 1772 KB Output is correct
24 Correct 36 ms 3180 KB Output is correct
25 Correct 37 ms 3180 KB Output is correct
26 Correct 44 ms 3308 KB Output is correct
27 Correct 33 ms 2924 KB Output is correct
28 Correct 52 ms 3436 KB Output is correct
29 Correct 39 ms 3308 KB Output is correct
30 Correct 37 ms 3308 KB Output is correct
31 Execution timed out 1574 ms 12824 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 22 ms 364 KB Output is correct
17 Correct 33 ms 2924 KB Output is correct
18 Correct 37 ms 3200 KB Output is correct
19 Correct 35 ms 2412 KB Output is correct
20 Correct 38 ms 3308 KB Output is correct
21 Correct 47 ms 3180 KB Output is correct
22 Correct 20 ms 2412 KB Output is correct
23 Correct 9 ms 1772 KB Output is correct
24 Correct 36 ms 3180 KB Output is correct
25 Correct 37 ms 3180 KB Output is correct
26 Correct 44 ms 3308 KB Output is correct
27 Correct 33 ms 2924 KB Output is correct
28 Correct 52 ms 3436 KB Output is correct
29 Correct 39 ms 3308 KB Output is correct
30 Correct 37 ms 3308 KB Output is correct
31 Execution timed out 1574 ms 12824 KB Time limit exceeded
32 Halted 0 ms 0 KB -