我的代码怎么了?POJ怎么了?
  • 板块灌水区
  • 楼主Wrong_Accept
  • 当前回复5
  • 已保存回复5
  • 发布时间2024/2/24 10:36
  • 上次更新2024/2/24 13:40:55
查看原帖
我的代码怎么了?POJ怎么了?
977599
Wrong_Accept楼主2024/2/24 10:36
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void solve()
{
    int n, ans = 0;
    cin >> n;
    vector<int> v(n);
    vector<vector<int>> f(n, vector<int>(n, 0));
    for (auto &w : v)
        cin >> w;
    for (int i = n - 1; i >= 0; i--)
        for (int j = 0; j < n - i; j++)
            f[j][j + i] = max((j - 1 >= 0) ? (f[j - 1][j + i] + v[j - 1] * (n - i - 1)) : 0, (j + i + 1 < n) ? (f[j][j + i + 1] + v[j + i + 1] * (n - i - 1)) : 0);
    for (int i = 0; i < n; i++)
        ans = max(ans, f[i][i] + v[i] * n);
    cout << ans << '\n';
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

SP740
本地和洛谷都没CE, 提交到一网站上(搬来的题)告诉我CE, 提交到你谷就UKE, 哪位大佬能告诉蒟蒻这是为什么

2024/2/24 10:36
加载中...