Submission #224553

# Submission time Handle Problem Language Result Execution time Memory
224553 2020-04-18T11:54:15 Z Autoratch Mountains (NOI20_mountains) C++14
24 / 100
435 ms 44300 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 3e5 + 3;

int n;
long long a[N];
vector<long long> s;
map<long long,int> ma;
long long fa[N],fb[N];
long long ans;

void update(long long (&a)[N],int idx,long long val){ idx++; while(idx<N) a[idx]+=val,idx+=(idx & -idx); }

long long read(long long (&a)[N],int idx){ idx++; long long val = 0; while(idx>0) val+=a[idx],idx-=(idx & -idx); return val; }

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> n;
    for(int i = 1;i <= n;i++) cin >> a[i],s.push_back(a[i]);
    sort(s.begin(),s.end());
    int id = 0;
    for(int x : s) if(!ma[x]) ma[x] = ++id;
    for(int i = 1;i <= n;i++) a[i] = ma[a[i]];
    for(int i = 1;i <= n;i++)
    {
        assert(a[i]<N);
        ans+=read(fb,N-2)-read(fb,a[i]);
        update(fb,a[i],read(fa,a[i]-1));
        update(fa,a[i],1);
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 417 ms 44000 KB Output is correct
3 Correct 424 ms 44300 KB Output is correct
4 Correct 406 ms 44000 KB Output is correct
5 Correct 435 ms 44128 KB Output is correct
6 Correct 411 ms 43996 KB Output is correct
7 Correct 408 ms 44000 KB Output is correct
8 Correct 415 ms 44000 KB Output is correct
9 Correct 243 ms 25952 KB Output is correct
10 Correct 245 ms 25952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 7276 KB Output is correct
2 Correct 62 ms 7412 KB Output is correct
3 Correct 60 ms 7284 KB Output is correct
4 Correct 61 ms 7284 KB Output is correct
5 Correct 61 ms 7284 KB Output is correct
6 Correct 64 ms 7284 KB Output is correct
7 Correct 68 ms 7276 KB Output is correct
8 Correct 56 ms 7196 KB Output is correct
9 Correct 56 ms 7284 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 7276 KB Output is correct
2 Correct 62 ms 7412 KB Output is correct
3 Correct 60 ms 7284 KB Output is correct
4 Correct 61 ms 7284 KB Output is correct
5 Correct 61 ms 7284 KB Output is correct
6 Correct 64 ms 7284 KB Output is correct
7 Correct 68 ms 7276 KB Output is correct
8 Correct 56 ms 7196 KB Output is correct
9 Correct 56 ms 7284 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 83 ms 7540 KB Output is correct
12 Correct 86 ms 7532 KB Output is correct
13 Correct 83 ms 7540 KB Output is correct
14 Correct 86 ms 7540 KB Output is correct
15 Correct 81 ms 7540 KB Output is correct
16 Correct 81 ms 7540 KB Output is correct
17 Correct 85 ms 7540 KB Output is correct
18 Correct 61 ms 7528 KB Output is correct
19 Correct 61 ms 7532 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 64 ms 7276 KB Output is correct
2 Correct 62 ms 7412 KB Output is correct
3 Correct 60 ms 7284 KB Output is correct
4 Correct 61 ms 7284 KB Output is correct
5 Correct 61 ms 7284 KB Output is correct
6 Correct 64 ms 7284 KB Output is correct
7 Correct 68 ms 7276 KB Output is correct
8 Correct 56 ms 7196 KB Output is correct
9 Correct 56 ms 7284 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 83 ms 7540 KB Output is correct
12 Correct 86 ms 7532 KB Output is correct
13 Correct 83 ms 7540 KB Output is correct
14 Correct 86 ms 7540 KB Output is correct
15 Correct 81 ms 7540 KB Output is correct
16 Correct 81 ms 7540 KB Output is correct
17 Correct 85 ms 7540 KB Output is correct
18 Correct 61 ms 7528 KB Output is correct
19 Correct 61 ms 7532 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 261 ms 13352 KB Output is correct
22 Correct 272 ms 13408 KB Output is correct
23 Correct 249 ms 13408 KB Output is correct
24 Correct 272 ms 13408 KB Output is correct
25 Correct 260 ms 13536 KB Output is correct
26 Correct 267 ms 13408 KB Output is correct
27 Correct 263 ms 13412 KB Output is correct
28 Correct 143 ms 13384 KB Output is correct
29 Correct 155 ms 13408 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 417 ms 44000 KB Output is correct
3 Correct 424 ms 44300 KB Output is correct
4 Correct 406 ms 44000 KB Output is correct
5 Correct 435 ms 44128 KB Output is correct
6 Correct 411 ms 43996 KB Output is correct
7 Correct 408 ms 44000 KB Output is correct
8 Correct 415 ms 44000 KB Output is correct
9 Correct 243 ms 25952 KB Output is correct
10 Correct 245 ms 25952 KB Output is correct
11 Correct 64 ms 7276 KB Output is correct
12 Correct 62 ms 7412 KB Output is correct
13 Correct 60 ms 7284 KB Output is correct
14 Correct 61 ms 7284 KB Output is correct
15 Correct 61 ms 7284 KB Output is correct
16 Correct 64 ms 7284 KB Output is correct
17 Correct 68 ms 7276 KB Output is correct
18 Correct 56 ms 7196 KB Output is correct
19 Correct 56 ms 7284 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 83 ms 7540 KB Output is correct
22 Correct 86 ms 7532 KB Output is correct
23 Correct 83 ms 7540 KB Output is correct
24 Correct 86 ms 7540 KB Output is correct
25 Correct 81 ms 7540 KB Output is correct
26 Correct 81 ms 7540 KB Output is correct
27 Correct 85 ms 7540 KB Output is correct
28 Correct 61 ms 7528 KB Output is correct
29 Correct 61 ms 7532 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Incorrect 5 ms 512 KB Output isn't correct
32 Halted 0 ms 0 KB -