当前位置:网站首页>DP energy Necklace
DP energy Necklace
2022-04-23 14:13:00 【Stingy old Sao】
Energy necklace
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
#define int long long
typedef long long LL;
typedef long long ll;
const int INF = 0x3f3f3f3f;
//const int inf = 1e18;
const int mod = 998244353;
//const int mod = 1e9 + 7;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
const int maxn = 1e4 + 10;
const int N = 6e6 + 100;
int dp[maxn][maxn];
int a[maxn];
int v[maxn];
void solve() {
int n;
cin>>n;
for (int i = 1; i <=n; ++i) {
cin>>a[i];
a[n+i]=a[i];
}
for(int len=3;len<=n+1;len++){
for(int l=1;l<=2*n-len+1;l++){
int r=l+len-1;
for(int k=l+1;k<r;k++){
dp[l][r]=max(dp[l][r],dp[l][k]+dp[k][r]+a[l]*a[k]*a[r]);
}
}
}
int res=0;
for(int i=1;i<=n;i++){
res=max(res,dp[i][i+n]);
}
cout<<res;
}
signed main() {
//ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _ = 1;
// cin >> _;
while (_--) {
solve();//cout<<"\n";
}
return 0;
}
//12341
//14321
//
版权声明
本文为[Stingy old Sao]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231407093980.html
边栏推荐
- mysql 5.1升级到5.69
- On September 8, the night before going to Songshan Lake
- rsync+inotify远程同步
- 关于云容灾,你需要知道这些
- Wechat applet initializes Bluetooth, searches nearby Bluetooth devices and connects designated Bluetooth (I)
- Wechat applet obtains login user information, openid and access_ token
- Redis数据库讲解(一)
- 拨开云雾synchronized使用五种方式介绍
- Research on recyclerview details - Discussion and repair of recyclerview click dislocation
- mysql 5.1升级到5.610
猜你喜欢
更改plsql工具栏的图标大小
PySide2
Installation and use of postman pit
Visio installation error 1:1935 2: {XXXXXXXX
Some experience of using dialogfragment and anti stepping pit experience (getactivity and getdialog are empty, cancelable is invalid, etc.)
政务云迁移实践 北明数科使用HyperMotion云迁移产品为某政府单位实施上云迁移项目,15天内完成近百套主机迁移
帆软报表设置单元格填报以及根据值的大小进行排名方法
回顾2021:如何帮助客户扫清上云最后一公里的障碍?
DeepinV20安装Mariadb
Jmeter设置环境变量支持在任意终端目录输入jmeter直接启动
随机推荐
帆软之单元格部分字体变颜色
Subscription number development of wechat applet (message push)
std::map 和 std::vector 内存释放
GFS分布式文件系统(理论)
线程间控制之Semaphore使用介绍
返回数组排序后下标
Can global variables be defined in header files
mysql 5.1升级到5.66
Use of WiFi module based on wechat applet
关于NodeJS中JSON5的相关配置和使用
squid代理
About the configuration and use of json5 in nodejs
pthread_ Why does self() repeat
倒计时1天~2022云容灾产品线上发布会即将开始
Wechat applet communicates with low-power Bluetooth - receives data sent by hardware (IV)
Mysql个人学习总结
RobotFramework 之 公共变量
Gartner预测云迁移规模大幅增长;云迁移的优势是什么?
CDH cluster integration Phoenix based on CM management
按实际取,每三级分类汇总一次,看图知需求