Submission #760925

# Submission time Handle Problem Language Result Execution time Memory
760925 2023-06-18T22:38:10 Z usuyus Cigle (COI21_cigle) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	int n; cin >> n;

	vector<int> bricks(n);
	for (int &x : bricks) cin >> x;

	vector dp(n+1, vector(n+1, 0));

	for (int i = 0; i <= n; i++) {

		for (int j = 1; j < i; j++) {
			dp[j][i] = max(dp[j][i], dp[j-1][i]);
		}

		int balance = 0;
		int matches = 0;
		int current = 0;

		for (int k = i+1, j = i; k <= n; k++) {

			balance += bricks[k-1];
			while (j > 0 && balance - bricks[j-1] >= 0) {
				balance -= bricks[--j];
			}

			dp[i][k] = max(dp[i][k-1], current);

			if (balance == 0) {
				matches++;
				if (j > 0) current = max(current, dp[j-1][i] + matches);
			}
		}
	}

	cout << dp[n-1][n] << endl;
}

Compilation message

cigle.cpp: In function 'int main()':
cigle.cpp:13:9: error: missing template arguments before 'dp'
   13 |  vector dp(n+1, vector(n+1, 0));
      |         ^~
cigle.cpp:18:4: error: 'dp' was not declared in this scope
   18 |    dp[j][i] = max(dp[j][i], dp[j-1][i]);
      |    ^~
cigle.cpp:32:4: error: 'dp' was not declared in this scope
   32 |    dp[i][k] = max(dp[i][k-1], current);
      |    ^~
cigle.cpp:41:10: error: 'dp' was not declared in this scope
   41 |  cout << dp[n-1][n] << endl;
      |          ^~