Submission #798586

# Submission time Handle Problem Language Result Execution time Memory
798586 2023-07-30T21:06:29 Z AndiR Mountains (NOI20_mountains) C++14
100 / 100
770 ms 44592 KB
#include <iostream>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
const int Nmax=300000;

ll n, v[Nmax];
set <ll> s;
map <ll, int> m;
int aib[Nmax+5];
ll sol[Nmax];
void aib_add(int pos){
    for (int i=pos; i<=n; i+=i&-i)
        aib[i]++;
}
int aib_check(int pos){
    int r=0;
    for (int i=pos; i>0; i-=i&-i)
        r+=aib[i];
    return r;
}
int main()
{
    cin>>n;
    for (int i=0; i<n; i++){
        cin>>v[i];
        s.insert(v[i]);
    }
    int ind=1;
    for (auto it=s.begin(); it!=s.end(); it++)
        m[*it]=ind++;
    for (int i=0; i<n; i++){
        aib_add(m[v[i]]);
        sol[i]=aib_check(m[v[i]]-1);
    }
    for (int i=0; i<=n; i++)
        aib[i]=0;
    ll t=0;
    for (int i=n-1; i>=0; i--){
        aib_add(m[v[i]]);
        t+=sol[i]*aib_check(m[v[i]]-1);
    }
    cout<<t;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 364 ms 44572 KB Output is correct
3 Correct 372 ms 44580 KB Output is correct
4 Correct 365 ms 44460 KB Output is correct
5 Correct 369 ms 44456 KB Output is correct
6 Correct 367 ms 44572 KB Output is correct
7 Correct 371 ms 44488 KB Output is correct
8 Correct 365 ms 44576 KB Output is correct
9 Correct 311 ms 28744 KB Output is correct
10 Correct 308 ms 28660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 6700 KB Output is correct
2 Correct 64 ms 6736 KB Output is correct
3 Correct 56 ms 6740 KB Output is correct
4 Correct 56 ms 6656 KB Output is correct
5 Correct 56 ms 6672 KB Output is correct
6 Correct 56 ms 6712 KB Output is correct
7 Correct 56 ms 6712 KB Output is correct
8 Correct 56 ms 6732 KB Output is correct
9 Correct 55 ms 6728 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 6700 KB Output is correct
2 Correct 64 ms 6736 KB Output is correct
3 Correct 56 ms 6740 KB Output is correct
4 Correct 56 ms 6656 KB Output is correct
5 Correct 56 ms 6672 KB Output is correct
6 Correct 56 ms 6712 KB Output is correct
7 Correct 56 ms 6712 KB Output is correct
8 Correct 56 ms 6732 KB Output is correct
9 Correct 55 ms 6728 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 105 ms 7012 KB Output is correct
12 Correct 103 ms 6956 KB Output is correct
13 Correct 101 ms 6988 KB Output is correct
14 Correct 103 ms 6956 KB Output is correct
15 Correct 104 ms 6904 KB Output is correct
16 Correct 102 ms 7000 KB Output is correct
17 Correct 104 ms 6928 KB Output is correct
18 Correct 61 ms 6940 KB Output is correct
19 Correct 61 ms 6988 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 12 ms 1760 KB Output is correct
12 Correct 12 ms 1748 KB Output is correct
13 Correct 12 ms 1748 KB Output is correct
14 Correct 12 ms 1752 KB Output is correct
15 Correct 12 ms 1704 KB Output is correct
16 Correct 14 ms 1776 KB Output is correct
17 Correct 12 ms 1776 KB Output is correct
18 Correct 12 ms 1108 KB Output is correct
19 Correct 5 ms 596 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 6700 KB Output is correct
2 Correct 64 ms 6736 KB Output is correct
3 Correct 56 ms 6740 KB Output is correct
4 Correct 56 ms 6656 KB Output is correct
5 Correct 56 ms 6672 KB Output is correct
6 Correct 56 ms 6712 KB Output is correct
7 Correct 56 ms 6712 KB Output is correct
8 Correct 56 ms 6732 KB Output is correct
9 Correct 55 ms 6728 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 105 ms 7012 KB Output is correct
12 Correct 103 ms 6956 KB Output is correct
13 Correct 101 ms 6988 KB Output is correct
14 Correct 103 ms 6956 KB Output is correct
15 Correct 104 ms 6904 KB Output is correct
16 Correct 102 ms 7000 KB Output is correct
17 Correct 104 ms 6928 KB Output is correct
18 Correct 61 ms 6940 KB Output is correct
19 Correct 61 ms 6988 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 387 ms 18300 KB Output is correct
22 Correct 356 ms 18280 KB Output is correct
23 Correct 351 ms 18252 KB Output is correct
24 Correct 353 ms 18236 KB Output is correct
25 Correct 345 ms 18292 KB Output is correct
26 Correct 346 ms 18352 KB Output is correct
27 Correct 351 ms 18304 KB Output is correct
28 Correct 191 ms 18236 KB Output is correct
29 Correct 191 ms 18212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 364 ms 44572 KB Output is correct
3 Correct 372 ms 44580 KB Output is correct
4 Correct 365 ms 44460 KB Output is correct
5 Correct 369 ms 44456 KB Output is correct
6 Correct 367 ms 44572 KB Output is correct
7 Correct 371 ms 44488 KB Output is correct
8 Correct 365 ms 44576 KB Output is correct
9 Correct 311 ms 28744 KB Output is correct
10 Correct 308 ms 28660 KB Output is correct
11 Correct 56 ms 6700 KB Output is correct
12 Correct 64 ms 6736 KB Output is correct
13 Correct 56 ms 6740 KB Output is correct
14 Correct 56 ms 6656 KB Output is correct
15 Correct 56 ms 6672 KB Output is correct
16 Correct 56 ms 6712 KB Output is correct
17 Correct 56 ms 6712 KB Output is correct
18 Correct 56 ms 6732 KB Output is correct
19 Correct 55 ms 6728 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 105 ms 7012 KB Output is correct
22 Correct 103 ms 6956 KB Output is correct
23 Correct 101 ms 6988 KB Output is correct
24 Correct 103 ms 6956 KB Output is correct
25 Correct 104 ms 6904 KB Output is correct
26 Correct 102 ms 7000 KB Output is correct
27 Correct 104 ms 6928 KB Output is correct
28 Correct 61 ms 6940 KB Output is correct
29 Correct 61 ms 6988 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 320 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 12 ms 1760 KB Output is correct
42 Correct 12 ms 1748 KB Output is correct
43 Correct 12 ms 1748 KB Output is correct
44 Correct 12 ms 1752 KB Output is correct
45 Correct 12 ms 1704 KB Output is correct
46 Correct 14 ms 1776 KB Output is correct
47 Correct 12 ms 1776 KB Output is correct
48 Correct 12 ms 1108 KB Output is correct
49 Correct 5 ms 596 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 387 ms 18300 KB Output is correct
52 Correct 356 ms 18280 KB Output is correct
53 Correct 351 ms 18252 KB Output is correct
54 Correct 353 ms 18236 KB Output is correct
55 Correct 345 ms 18292 KB Output is correct
56 Correct 346 ms 18352 KB Output is correct
57 Correct 351 ms 18304 KB Output is correct
58 Correct 191 ms 18236 KB Output is correct
59 Correct 191 ms 18212 KB Output is correct
60 Correct 0 ms 212 KB Output is correct
61 Correct 738 ms 44480 KB Output is correct
62 Correct 723 ms 44572 KB Output is correct
63 Correct 720 ms 44520 KB Output is correct
64 Correct 693 ms 44572 KB Output is correct
65 Correct 722 ms 44492 KB Output is correct
66 Correct 770 ms 44592 KB Output is correct
67 Correct 766 ms 44572 KB Output is correct
68 Correct 530 ms 28744 KB Output is correct
69 Correct 374 ms 22220 KB Output is correct
70 Correct 1 ms 212 KB Output is correct