Submission #680201

# Submission time Handle Problem Language Result Execution time Memory
680201 2023-01-10T08:04:12 Z abcvuitunggio Mountains (NOI20_mountains) C++17
100 / 100
254 ms 29364 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#define int long long
using namespace std;
int n,a[300001],res,ft[300001];
vector <int> v,ve[300001];
void update(int i){
    for (;i<=n;i+=i&(-i))
        ft[i]++;
}
int get(int i){
    int res=0;
    for (;i;i-=i&(-i))
        res+=ft[i];
    return res;
}
int32_t main(){
    ios_base::sync_with_stdio(NULL);cin.tie(nullptr);
    //freopen("xyz.inp","r",stdin);
    //freopen("xyz.out","w",stdout);
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> a[i];
        v.push_back(a[i]);
    }
    sort(v.begin(),v.end());
    v.resize(unique(v.begin(),v.end())-v.begin());
    for (int i=1;i<=n;i++){
        a[i]=lower_bound(v.begin(),v.end(),a[i])-v.begin()+1;
        ve[a[i]].push_back(i);
    }
    for (int i=1;i<=n;i++)
        if (!ve[i].empty()){
            for (int j:ve[i])
                res+=get(j-1)*(get(n)-get(j));
            for (int j:ve[i])
                update(j);
        }
    cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7380 KB Output is correct
2 Correct 103 ms 29312 KB Output is correct
3 Correct 106 ms 29364 KB Output is correct
4 Correct 99 ms 29264 KB Output is correct
5 Correct 101 ms 29256 KB Output is correct
6 Correct 95 ms 29248 KB Output is correct
7 Correct 105 ms 29236 KB Output is correct
8 Correct 104 ms 29236 KB Output is correct
9 Correct 107 ms 25532 KB Output is correct
10 Correct 100 ms 25448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 20292 KB Output is correct
2 Correct 57 ms 20236 KB Output is correct
3 Correct 57 ms 19568 KB Output is correct
4 Correct 49 ms 19700 KB Output is correct
5 Correct 68 ms 20248 KB Output is correct
6 Correct 54 ms 19528 KB Output is correct
7 Correct 47 ms 19584 KB Output is correct
8 Correct 46 ms 19332 KB Output is correct
9 Correct 43 ms 19412 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 20292 KB Output is correct
2 Correct 57 ms 20236 KB Output is correct
3 Correct 57 ms 19568 KB Output is correct
4 Correct 49 ms 19700 KB Output is correct
5 Correct 68 ms 20248 KB Output is correct
6 Correct 54 ms 19528 KB Output is correct
7 Correct 47 ms 19584 KB Output is correct
8 Correct 46 ms 19332 KB Output is correct
9 Correct 43 ms 19412 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
11 Correct 66 ms 18492 KB Output is correct
12 Correct 67 ms 18564 KB Output is correct
13 Correct 63 ms 18560 KB Output is correct
14 Correct 65 ms 18676 KB Output is correct
15 Correct 73 ms 18528 KB Output is correct
16 Correct 70 ms 18488 KB Output is correct
17 Correct 70 ms 18552 KB Output is correct
18 Correct 45 ms 18120 KB Output is correct
19 Correct 45 ms 18072 KB Output is correct
20 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 4 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 4 ms 7384 KB Output is correct
5 Correct 4 ms 7380 KB Output is correct
6 Correct 4 ms 7508 KB Output is correct
7 Correct 4 ms 7380 KB Output is correct
8 Correct 4 ms 7380 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 4 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 4 ms 7384 KB Output is correct
5 Correct 4 ms 7380 KB Output is correct
6 Correct 4 ms 7508 KB Output is correct
7 Correct 4 ms 7380 KB Output is correct
8 Correct 4 ms 7380 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
11 Correct 9 ms 8116 KB Output is correct
12 Correct 8 ms 8020 KB Output is correct
13 Correct 8 ms 8112 KB Output is correct
14 Correct 9 ms 8020 KB Output is correct
15 Correct 9 ms 8028 KB Output is correct
16 Correct 10 ms 8024 KB Output is correct
17 Correct 9 ms 8112 KB Output is correct
18 Correct 9 ms 7900 KB Output is correct
19 Correct 6 ms 7764 KB Output is correct
20 Correct 4 ms 7376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 20292 KB Output is correct
2 Correct 57 ms 20236 KB Output is correct
3 Correct 57 ms 19568 KB Output is correct
4 Correct 49 ms 19700 KB Output is correct
5 Correct 68 ms 20248 KB Output is correct
6 Correct 54 ms 19528 KB Output is correct
7 Correct 47 ms 19584 KB Output is correct
8 Correct 46 ms 19332 KB Output is correct
9 Correct 43 ms 19412 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
11 Correct 66 ms 18492 KB Output is correct
12 Correct 67 ms 18564 KB Output is correct
13 Correct 63 ms 18560 KB Output is correct
14 Correct 65 ms 18676 KB Output is correct
15 Correct 73 ms 18528 KB Output is correct
16 Correct 70 ms 18488 KB Output is correct
17 Correct 70 ms 18552 KB Output is correct
18 Correct 45 ms 18120 KB Output is correct
19 Correct 45 ms 18072 KB Output is correct
20 Correct 4 ms 7380 KB Output is correct
21 Correct 140 ms 20976 KB Output is correct
22 Correct 161 ms 21000 KB Output is correct
23 Correct 148 ms 21048 KB Output is correct
24 Correct 137 ms 20968 KB Output is correct
25 Correct 174 ms 21016 KB Output is correct
26 Correct 144 ms 21148 KB Output is correct
27 Correct 140 ms 21156 KB Output is correct
28 Correct 78 ms 20520 KB Output is correct
29 Correct 77 ms 20532 KB Output is correct
30 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7380 KB Output is correct
2 Correct 103 ms 29312 KB Output is correct
3 Correct 106 ms 29364 KB Output is correct
4 Correct 99 ms 29264 KB Output is correct
5 Correct 101 ms 29256 KB Output is correct
6 Correct 95 ms 29248 KB Output is correct
7 Correct 105 ms 29236 KB Output is correct
8 Correct 104 ms 29236 KB Output is correct
9 Correct 107 ms 25532 KB Output is correct
10 Correct 100 ms 25448 KB Output is correct
11 Correct 48 ms 20292 KB Output is correct
12 Correct 57 ms 20236 KB Output is correct
13 Correct 57 ms 19568 KB Output is correct
14 Correct 49 ms 19700 KB Output is correct
15 Correct 68 ms 20248 KB Output is correct
16 Correct 54 ms 19528 KB Output is correct
17 Correct 47 ms 19584 KB Output is correct
18 Correct 46 ms 19332 KB Output is correct
19 Correct 43 ms 19412 KB Output is correct
20 Correct 4 ms 7380 KB Output is correct
21 Correct 66 ms 18492 KB Output is correct
22 Correct 67 ms 18564 KB Output is correct
23 Correct 63 ms 18560 KB Output is correct
24 Correct 65 ms 18676 KB Output is correct
25 Correct 73 ms 18528 KB Output is correct
26 Correct 70 ms 18488 KB Output is correct
27 Correct 70 ms 18552 KB Output is correct
28 Correct 45 ms 18120 KB Output is correct
29 Correct 45 ms 18072 KB Output is correct
30 Correct 4 ms 7380 KB Output is correct
31 Correct 4 ms 7380 KB Output is correct
32 Correct 4 ms 7380 KB Output is correct
33 Correct 4 ms 7380 KB Output is correct
34 Correct 4 ms 7384 KB Output is correct
35 Correct 4 ms 7380 KB Output is correct
36 Correct 4 ms 7508 KB Output is correct
37 Correct 4 ms 7380 KB Output is correct
38 Correct 4 ms 7380 KB Output is correct
39 Correct 4 ms 7380 KB Output is correct
40 Correct 4 ms 7380 KB Output is correct
41 Correct 9 ms 8116 KB Output is correct
42 Correct 8 ms 8020 KB Output is correct
43 Correct 8 ms 8112 KB Output is correct
44 Correct 9 ms 8020 KB Output is correct
45 Correct 9 ms 8028 KB Output is correct
46 Correct 10 ms 8024 KB Output is correct
47 Correct 9 ms 8112 KB Output is correct
48 Correct 9 ms 7900 KB Output is correct
49 Correct 6 ms 7764 KB Output is correct
50 Correct 4 ms 7376 KB Output is correct
51 Correct 140 ms 20976 KB Output is correct
52 Correct 161 ms 21000 KB Output is correct
53 Correct 148 ms 21048 KB Output is correct
54 Correct 137 ms 20968 KB Output is correct
55 Correct 174 ms 21016 KB Output is correct
56 Correct 144 ms 21148 KB Output is correct
57 Correct 140 ms 21156 KB Output is correct
58 Correct 78 ms 20520 KB Output is correct
59 Correct 77 ms 20532 KB Output is correct
60 Correct 4 ms 7380 KB Output is correct
61 Correct 254 ms 29284 KB Output is correct
62 Correct 211 ms 29272 KB Output is correct
63 Correct 234 ms 29304 KB Output is correct
64 Correct 211 ms 29308 KB Output is correct
65 Correct 230 ms 29304 KB Output is correct
66 Correct 227 ms 29236 KB Output is correct
67 Correct 211 ms 29272 KB Output is correct
68 Correct 212 ms 25460 KB Output is correct
69 Correct 160 ms 21628 KB Output is correct
70 Correct 4 ms 7380 KB Output is correct