QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#165715#5500. Barsarseny_y#WA 3183ms3600kbC++231.7kb2023-09-05 21:08:252023-09-05 21:08:25

Judging History

你现在查看的是最新测评结果

  • [2023-09-05 21:08:25]
  • 评测
  • 测评结果:WA
  • 用时:3183ms
  • 内存:3600kb
  • [2023-09-05 21:08:25]
  • 提交

answer

//I wrote this code 4 u today
#include <bits/stdc++.h>

template<class t> using vc = std::vector<t>;

#define nd node*
#define pnd pair<nd, nd>

typedef long long ll;

template<const ll MOD>
struct mod_mul : std::multiplies<const ll> {
    ll operator()(const ll a, const ll b) {
        return (a * b) % MOD;
    }
};


template<typename T>
inline void sort(T &a) {
    std::sort(a.begin(), a.end());
}

template<typename T>
inline void unique(T &a) {
    a.resize(std::unique(a.begin(), a.end()) - a.begin());
}

template<typename T>
inline void reverse(T &a) {
    std::reverse(a.begin(), a.end());
}

const ll INF = 9023372036854775808ll;
const ll MOD = 1000000007ll;

using namespace std;

const int K = 228;

mt19937 rnd(228);

int32_t main() {
    std::cin.tie(nullptr)->ios_base::sync_with_stdio(false);
#define int ll
    ll t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (auto &i : a) {
            cin >> i;
        }
        vector<int> dp(n + 1, 0);
        a.insert(a.begin(), 0);
        int mx = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = i - 1; j >= max(1LL, i - K); --j) {
                dp[i] = max(dp[i], dp[j] + (i - j) * (a[i] + a[j]));
            }
            for (int j = 1; j <= K && j < i; ++j) {
                dp[i] = max(dp[i], dp[j] + (i - j) * (a[i] + a[j]));
            }
            for (int c = 0; c < K; ++c) {
                if (i != 1) {
                    int j = rnd() % (i - 1) + 1;
                    dp[i] = max(dp[i], dp[j] + (i - j) * (a[i] + a[j]));
                }
            }
            mx = max(mx, (n - i) * a[i] + dp[i]);
        }
        cout << mx << "\n";
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3600kb

input:

2
4
5 2 2 6
5
1 5 4 4 1

output:

33
29

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 3183ms
memory: 3584kb

input:

10000
4
5 2 2 6
5
1 5 4 4 1
197
763787596 15221694 898228999 187472305 466351873 822742732 437754202 800092772 843092246 915675776 166265020 346340615 796714085 497548541 182089610 64356048 363276768 181268733 257949015 236568898 752096761 928725929 443146784 114577469 833053207 38120723 14891030 41...

output:

33
29
382465638565
663641330002
550288673161
458946673513
296420749955
875760099157
632854843886
586309163102
225238173690
716890380495
466644027129
283505446030
585094154153
201707398762
336548832140
483300272586
606382970973
587469399170
408018096564
827347820764
975377092201
925120038848
26408806...

result:

wrong answer 3303rd lines differ - expected: '37383850271649', found: '37358503072341'