Submission #989136

# Submission time Handle Problem Language Result Execution time Memory
989136 2024-05-27T15:14:55 Z Chal1k Bigger segments (IZhO19_segments) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <math.h>
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define SPEED ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define str string
#define pb push_back
#define pf push_front
#define nl "\n"
#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second
#define len(a) a.size()
#define sz(v) (int)(v.size())
#define pii pair<int,int>
const int N = 5e5 + 1;
const int md = 998244353;
const int mod = 1e9 + 7;
const int mega = 1e6 + 3;
const int inf = 1e9;
int n , a[N + 1] , dp[3005][3005] , pref[N] , suf[3005][3005];
void solve(){
    cin >> n;
    for(int i = 1; i <= n; ++i)cin >> a[i] , pref[i] = pref[i - 1] + a[i];
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            dp[i][j] = suf[i][j] =  -inf;
        }
    }
    suf[1][1] = 1;
    for(int i = 1; i <= n; ++ i) dp[1][i] = 1;
    for(int i = 1; i <= n; ++i){
        for(int j = i; j >= 1; j--){
            int  l = 1 , r = j - 1 , res = -1;
            while(l <= r){
                int m = (l + r) / 2;
                if(pref[j - 1] - pref[mid - 1] >= pref[j - 1] + pref[i]){
                    r = mid - 1;
                    res = mid;
                }
                else l = mid + 1;
            }
            if(k != -1)dp[j][i] = max(dp[j][i] , suf[k][j - 1] + 1);
        }
        suf[i][i] = dp[i][i];
        for(int j = i - 1; j >= 1; --j)suf[j][i] = max(dp[j][i], suf[j + 1][i]);
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i)ans = max(dp[i][n] , ans);
    cout << ans << nl;
}
signed main(){
    SPEED;
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    #ifndef ONLINE_JUDGE
    cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}

Compilation message

segments.cpp: In function 'void solve()':
segments.cpp:42:39: error: 'mid' was not declared in this scope; did you mean 'mod'?
   42 |                 if(pref[j - 1] - pref[mid - 1] >= pref[j - 1] + pref[i]){
      |                                       ^~~
      |                                       mod
segments.cpp:41:21: warning: unused variable 'm' [-Wunused-variable]
   41 |                 int m = (l + r) / 2;
      |                     ^
segments.cpp:48:16: error: 'k' was not declared in this scope
   48 |             if(k != -1)dp[j][i] = max(dp[j][i] , suf[k][j - 1] + 1);
      |                ^