Submission #1094219

#TimeUsernameProblemLanguageResultExecution timeMemory
1094219Trisanu_DasFeast (NOI19_feast)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int dp[2005][2005];

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, k; cin >> n >> k;
  int a[n + 1]; for(int i = 1; i <= n; i++) cin >> a[i];
  for(int i = 1; i <= n; i++) a[i] += a[i - 1];
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= k; j++){
      dp[i][j] = max(dp[i][j], dp[i - 1][j]);
      for(int l = 0; l < i; l++) dp[i][j] = max(dp[i][j], dp[l][j - 1] + a[i] - a[p]);
    }
  }
  cout << dp[n][k];
}

Compilation message (stderr)

feast.cpp: In function 'int main()':
feast.cpp:15:83: error: 'p' was not declared in this scope
   15 |       for(int l = 0; l < i; l++) dp[i][j] = max(dp[i][j], dp[l][j - 1] + a[i] - a[p]);
      |                                                                                   ^