제출 #344552

#제출 시각아이디문제언어결과실행 시간메모리
344552tata666Bigger segments (IZhO19_segments)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second using namespace std; typedef long long llong; const int MOD = 1e9 + 7; const int MXN = 4e5 + 7; const llong INF = 1e18 + 7; int n, ans int dp[3001][3001]; llong pref[MXN], a[MXN]; int main(){ ios_base::sync_with_stdio(0); //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; dp[1][i] = 1; pref[i] = pref[i - 1] + a[i]; } for(int i = 1; i <= n; i++){ for(int j = i; j <= n; j++){ for(int k = j + 1; k <= n; k++){ if(pref[j] - pref[i - 1] <= pref[k] - pref[j]){ dp[j + 1][k] = max(dp[j + 1][k], dp[i][j] + 1); } } } } for(int i = 1; i <= n; i++){ ans = max(dp[i][n], ans); } cout << ans; return 0; }

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

segments.cpp:16:1: error: expected initializer before 'int'
   16 | int dp[3001][3001];
      | ^~~
segments.cpp: In function 'int main()':
segments.cpp:26:5: error: 'dp' was not declared in this scope
   26 |     dp[1][i] = 1;
      |     ^~
segments.cpp:33:11: error: 'dp' was not declared in this scope
   33 |           dp[j + 1][k] = max(dp[j + 1][k], dp[i][j] + 1);
      |           ^~
segments.cpp:39:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |     ans = max(dp[i][n], ans);
      |     ^~~
      |     abs
segments.cpp:39:15: error: 'dp' was not declared in this scope
   39 |     ans = max(dp[i][n], ans);
      |               ^~
segments.cpp:41:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   41 |   cout << ans;
      |           ^~~
      |           abs