Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std; const int maxn = 1005; typedef long long ll; int dp[maxn][maxn]; ll pref_sum[maxn]; int rec(int i, int j) { for(int k = i; k < j; k++) { if(pref_sum[k] * 2 == pref_sum[j] + pref_sum[i - 1]) { return max(rec(i, k), rec(k + 1, j)) + 1; } } return 0; } int main() { ios_base::sync_with_stdio(false); int t; cin >> t; while(t--) { memset(pref_sum, 0, sizeof pref_sum); int n; cin >> n; ll s = 0; for(int i = 1 ; i <= n; i++) { cin >> pref_sum[i]; pref_sum[i] += pref_sum[i - 1]; } cout << rec(1, n) << endl; } return 0; } /* 5 9 7 ...##.... ..#.##..# ..#....## .##...#.. ....#.... WS?EE?? **/
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)