社区讨论
t怎么求?
P2858[USACO06FEB] Treats for the Cows G/S参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @ly448ucc
- 此快照首次捕获于
- 2024/07/02 15:57 2 年前
- 此快照最后确认于
- 2024/07/02 18:41 2 年前
CPP
#undef wrap
#undef print
#include<bits/stdc++.h>
using namespace std;
#define wrap() printf("\n")
typedef long long int ll;
typedef int si;
typedef unsigned int ui;
typedef unsigned long long ull;
//typedef unsigned __int128 uint128;
const int E = 1e6*4+10;
const int S = 1e7+10;
const int U = 1<<30;
const int T = 1e4*2+10;
const int F = 65540;//F = 65535 + 5
const int Q = 3010;
const long long Y = 1LL<<60LL;
const int maxp = 1e5 + 10;
void print(int t){printf("%d",t);}
void print(long long t){printf("%lld",t);}
void print(string t){cout << t;}
void print(int t,bool b,bool c)
{
printf("%d",t);
if(b) wrap();
if(c) print(" ");
}
void print(long long t,bool b,bool c)
{
printf("%lld",t);
if(b) wrap();
if(c) print(" ");
}
void print(string t,bool b,bool c)
{
cout << t;
if(b) wrap();
if(c) print(" ");
}
ll gcd(ll a,ll b)
{
if(b==0)return a;
return gcd(b,a%b);
}
ll lcm(ll a, ll b)
{
long long temp = a * b;
temp = temp / gcd(a, b);
return temp;
}
si gcd(si a,si b)
{
if(b==0)return a;
return gcd(b,a%b);
}
si lcm(si a, si b)
{
si temp = a * b;
temp = temp / gcd(a, b);
return temp;
}
ll gcd(si a,ll b)
{
if(b==0)return a;
return gcd(b,a%b);
}
ll lcm(si a, ll b)
{
long long temp = a * b;
temp = temp / gcd(a, b);
return temp;
}
ll gcd(ll a,si b)
{
if(b==0)return a;
return gcd(b,a%b);
}
ll lcm(ll a, si b)
{
long long temp = a * b;
temp = temp / gcd(a, b);
return temp;
}
int n,a[E],ans,f[Q][Q];
int main()
{
cin >> n;
for(int i=1;i<=n;i++) cin >> a[i];
for(int i=1;i<=n;i++)f[i][i]=a[i]*n;
for(int d=1;d<n;d++)
{
for(int l=1;l<=n-d;l++)
{
int r = l+d;
int t =
if(r > n) continue;
f[l][r] = max(f[l+1][r]+t*a[l],f[l][r-1]+t*a[r]);
}
}
cout << f[1][n];
}
#undef wrap
#undef print
回复
共 0 条回复,欢迎继续交流。
正在加载回复...