QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#418795#8685. Doing the Container Shufflelight_ink_dotsWA 95ms70136kbC++14964b2024-05-23 15:49:102024-05-23 15:49:11

Judging History

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

  • [2024-05-23 15:49:11]
  • 评测
  • 测评结果:WA
  • 用时:95ms
  • 内存:70136kb
  • [2024-05-23 15:49:10]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main() {
    static const int maxn = 1000010;
    static int n;
    scanf("%d", &n);
    static int a[maxn], r[maxn];
    static vector<int> vec[maxn];
    for (int i = 1; i <= n; i++) scanf("%d", a + i), r[a[i]] = i;
    for (int i = 1; i <= n - 2; i++) vec[min(r[i], r[i + 1])].push_back(i + 2);
    struct BIT {
        int a[maxn];
        inline void insert(const int p) {
            for (int i = p; i; i -= i & -i) a[i]++;
            return;
        }
        inline int query(const int p) {
            int ret = 0;
            for (int i = p; i <= n; i += i & -i) ret += a[i];
            return ret;
        }
    };
    static BIT t;
    int ans = (n * (n - 1) >> 1) + (n << 1) - (r[1] - 1);
    for (int i = 1; i <= n; i++) {
        for (int p : vec[i]) ans -= t.query(p);
        t.insert(a[i]);
    }
    printf("%d.%d\n", ans >> 1, (ans & 1) * 5);
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 6ms
memory: 31172kb

input:

1
1

output:

1.0

result:

ok found '1.00000', expected '1.00000', error '0.00000'

Test #2:

score: 0
Accepted
time: 4ms
memory: 30492kb

input:

11
5 9 1 3 11 10 2 4 6 8 7

output:

31.5

result:

ok found '31.50000', expected '31.50000', error '0.00000'

Test #3:

score: -100
Wrong Answer
time: 95ms
memory: 70136kb

input:

1000000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...

output:

-181094992.0

result:

wrong answer 1st numbers differ - expected: '250000750000.00000', found: '-181094992.00000', error = '1.00072'