제출 #628050

#제출 시각아이디문제언어결과실행 시간메모리
628050BackNoobBigger segments (IZhO19_segments)C++14
27 / 100
1590 ms38228 KiB
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se se cond
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;
const int mxN = 3227;
const int inf = 1e9 + 7;
const int infll = 1e18 + 7;

int n;
int a[mxN];
ll pre[mxN];
int dp[mxN][mxN];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("task.inp", "r", stdin);
    //freopen("task.out", "w", stdout);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];


    for(int i = 1; i <= n; i++) pre[i] = pre[i - 1] + a[i];

    for(int i = 0; i <= n; i++)
    for(int j = 0; j <= n; j++) dp[i][j] = -inf;

    for(int i = 1; i <= n; i++) dp[0][i] = 1;

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= i; j++) {
            for(int k = 0; k <= j; k++) {
                if(pre[i] - pre[j] >= pre[j] - pre[k] && dp[k][j] > 0) {
                    dp[j][i] = max(dp[j][i], dp[k][j] + 1);
                }
            }
        }
    }

    int ans = 0;
    for(int i = 0; i <= n; i++) ans= max(ans, dp[i][n]);
    cout << ans;

}

컴파일 시 표준 에러 (stderr) 메시지

segments.cpp:10:24: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   10 | const int infll = 1e18 + 7;
      |                   ~~~~~^~~
#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...