QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#329424#8050. Random Permutationucup-team1209WA 1667ms6116kbC++231.1kb2024-02-16 17:41:492024-02-16 17:41:49

Judging History

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

  • [2024-02-16 17:41:49]
  • 评测
  • 测评结果:WA
  • 用时:1667ms
  • 内存:6116kb
  • [2024-02-16 17:41:49]
  • 提交

answer

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
using std::cin;
using std::cout;

using ll = long long;
int n;

const int N = 300005;
int p[N];

int mem[N * 2];
int * cnt = mem + N;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    for(int i = 1;i <= n;++i) {
        cin >> p[i];
    }
    ll ans = 0;
    for(int i = 1;i <= n;++i) {
        ll L = n / (std::abs((p[i] - n / 2)) + 1) + 1;
        L = L * L * 6;
        int l = std::max<ll>(1, i - L), r = std::min<ll>(n, i + L);
        int sum = 0;
        const int V = p[i];
        const int R = i - l;
        int cc = 0;
        cnt[0] = 1;
        for(int j = l;j < i;++j) {
            sum += p[j] >= V ? 1 : -1;
            cnt[sum] += 1;
        }
        for(int j = i;j <= r;++j) {
            sum += p[j] >= V ? 1 : -1;
            cc += cnt[sum - 1] + cnt[sum - 2];
        }
        ans += cc * p[i];
        sum = 0;
        memset(cnt - R, 0, 4 * (R + R + 1));
//        if(i % 10000 == 0) std::cerr << i << std::endl;
    }
    cout << ans << '\n';
}

詳細信息

Test #1:

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

input:

4
1 4 2 3

output:

22

result:

ok 1 number(s): "22"

Test #2:

score: -100
Wrong Answer
time: 1667ms
memory: 6116kb

input:

100000
56449 21738 74917 44834 36187 96576 37204 28451 3444 13029 66039 8955 51445 30706 27229 37159 66052 16691 70389 29935 44984 3648 75082 73600 76621 28345 5298 37940 49412 85260 92029 18185 84398 10233 79227 98312 96649 30680 65206 38879 75397 26951 11294 58085 37297 97167 59252 44104 4058 3796...

output:

2309851277842

result:

wrong answer 1st numbers differ - expected: '250202478701074', found: '2309851277842'