답안 #287122

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
287122 2020-08-31T12:17:05 Z sabamaku Mountains (NOI20_mountains) C++14
100 / 100
1494 ms 34332 KB
#include<bits/stdc++.h>
using namespace std;

long long n,x,p[3][300005],ans,d[300005],sum,sum1,s[300005];

map <long long,int> mp;

void update(int a){
    for(int i = a; i <= n; i += (i & -i)){
        p[x][i]++;
    }
}

void deleteit(int a){
    for(int i = a; i <= n; i += (i & -i)){
        p[1][i]--;
    }
}

void solve(int a){
    sum = 0;
    for(int i = a - 1; i >= 1; i -= (i & -i)){
        sum += p[x][i];
    }
}

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> d[i];
        s[i] = d[i];
    }
    sort(s + 1, s + n + 1);
    for(int i = 1; i <= n; i++){
        if(mp[s[i]] == 0){
            x++;
            mp[s[i]] = x; 
        }
    }
    x = 1;
    for(int i = n; i >= 2; i--){
        update(mp[d[i]]);
    }
    for(int i = 2; i < n; i++){
        deleteit(mp[d[i]]);
        x = 0;
        update(mp[d[i - 1]]);
        x = 1;
        solve(mp[d[i]]);
        sum1 = sum;
        x = 0;
        solve(mp[d[i]]);
        ans += sum * sum1;
        //cout << sum << " " << sum1 << " " << mp[d[i]] << endl;
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 772 ms 34004 KB Output is correct
3 Correct 772 ms 34040 KB Output is correct
4 Correct 771 ms 34168 KB Output is correct
5 Correct 770 ms 34040 KB Output is correct
6 Correct 766 ms 34168 KB Output is correct
7 Correct 769 ms 34168 KB Output is correct
8 Correct 769 ms 34168 KB Output is correct
9 Correct 709 ms 22904 KB Output is correct
10 Correct 707 ms 22764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 136 ms 5112 KB Output is correct
2 Correct 138 ms 5756 KB Output is correct
3 Correct 140 ms 5704 KB Output is correct
4 Correct 142 ms 5752 KB Output is correct
5 Correct 139 ms 5624 KB Output is correct
6 Correct 140 ms 5752 KB Output is correct
7 Correct 139 ms 5752 KB Output is correct
8 Correct 134 ms 5752 KB Output is correct
9 Correct 133 ms 5752 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 136 ms 5112 KB Output is correct
2 Correct 138 ms 5756 KB Output is correct
3 Correct 140 ms 5704 KB Output is correct
4 Correct 142 ms 5752 KB Output is correct
5 Correct 139 ms 5624 KB Output is correct
6 Correct 140 ms 5752 KB Output is correct
7 Correct 139 ms 5752 KB Output is correct
8 Correct 134 ms 5752 KB Output is correct
9 Correct 133 ms 5752 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 210 ms 6008 KB Output is correct
12 Correct 206 ms 6004 KB Output is correct
13 Correct 206 ms 6008 KB Output is correct
14 Correct 205 ms 5972 KB Output is correct
15 Correct 213 ms 6008 KB Output is correct
16 Correct 207 ms 6008 KB Output is correct
17 Correct 210 ms 6008 KB Output is correct
18 Correct 161 ms 5968 KB Output is correct
19 Correct 163 ms 6004 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 27 ms 1400 KB Output is correct
12 Correct 27 ms 1536 KB Output is correct
13 Correct 27 ms 1536 KB Output is correct
14 Correct 27 ms 1536 KB Output is correct
15 Correct 27 ms 1532 KB Output is correct
16 Correct 27 ms 1528 KB Output is correct
17 Correct 27 ms 1536 KB Output is correct
18 Correct 24 ms 1024 KB Output is correct
19 Correct 9 ms 640 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 136 ms 5112 KB Output is correct
2 Correct 138 ms 5756 KB Output is correct
3 Correct 140 ms 5704 KB Output is correct
4 Correct 142 ms 5752 KB Output is correct
5 Correct 139 ms 5624 KB Output is correct
6 Correct 140 ms 5752 KB Output is correct
7 Correct 139 ms 5752 KB Output is correct
8 Correct 134 ms 5752 KB Output is correct
9 Correct 133 ms 5752 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 210 ms 6008 KB Output is correct
12 Correct 206 ms 6004 KB Output is correct
13 Correct 206 ms 6008 KB Output is correct
14 Correct 205 ms 5972 KB Output is correct
15 Correct 213 ms 6008 KB Output is correct
16 Correct 207 ms 6008 KB Output is correct
17 Correct 210 ms 6008 KB Output is correct
18 Correct 161 ms 5968 KB Output is correct
19 Correct 163 ms 6004 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 779 ms 14380 KB Output is correct
22 Correct 772 ms 14456 KB Output is correct
23 Correct 780 ms 14304 KB Output is correct
24 Correct 772 ms 14456 KB Output is correct
25 Correct 773 ms 14328 KB Output is correct
26 Correct 780 ms 14328 KB Output is correct
27 Correct 769 ms 14264 KB Output is correct
28 Correct 384 ms 14200 KB Output is correct
29 Correct 383 ms 14200 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 772 ms 34004 KB Output is correct
3 Correct 772 ms 34040 KB Output is correct
4 Correct 771 ms 34168 KB Output is correct
5 Correct 770 ms 34040 KB Output is correct
6 Correct 766 ms 34168 KB Output is correct
7 Correct 769 ms 34168 KB Output is correct
8 Correct 769 ms 34168 KB Output is correct
9 Correct 709 ms 22904 KB Output is correct
10 Correct 707 ms 22764 KB Output is correct
11 Correct 136 ms 5112 KB Output is correct
12 Correct 138 ms 5756 KB Output is correct
13 Correct 140 ms 5704 KB Output is correct
14 Correct 142 ms 5752 KB Output is correct
15 Correct 139 ms 5624 KB Output is correct
16 Correct 140 ms 5752 KB Output is correct
17 Correct 139 ms 5752 KB Output is correct
18 Correct 134 ms 5752 KB Output is correct
19 Correct 133 ms 5752 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 210 ms 6008 KB Output is correct
22 Correct 206 ms 6004 KB Output is correct
23 Correct 206 ms 6008 KB Output is correct
24 Correct 205 ms 5972 KB Output is correct
25 Correct 213 ms 6008 KB Output is correct
26 Correct 207 ms 6008 KB Output is correct
27 Correct 210 ms 6008 KB Output is correct
28 Correct 161 ms 5968 KB Output is correct
29 Correct 163 ms 6004 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 512 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 1 ms 384 KB Output is correct
40 Correct 0 ms 384 KB Output is correct
41 Correct 27 ms 1400 KB Output is correct
42 Correct 27 ms 1536 KB Output is correct
43 Correct 27 ms 1536 KB Output is correct
44 Correct 27 ms 1536 KB Output is correct
45 Correct 27 ms 1532 KB Output is correct
46 Correct 27 ms 1528 KB Output is correct
47 Correct 27 ms 1536 KB Output is correct
48 Correct 24 ms 1024 KB Output is correct
49 Correct 9 ms 640 KB Output is correct
50 Correct 0 ms 384 KB Output is correct
51 Correct 779 ms 14380 KB Output is correct
52 Correct 772 ms 14456 KB Output is correct
53 Correct 780 ms 14304 KB Output is correct
54 Correct 772 ms 14456 KB Output is correct
55 Correct 773 ms 14328 KB Output is correct
56 Correct 780 ms 14328 KB Output is correct
57 Correct 769 ms 14264 KB Output is correct
58 Correct 384 ms 14200 KB Output is correct
59 Correct 383 ms 14200 KB Output is correct
60 Correct 1 ms 384 KB Output is correct
61 Correct 1494 ms 34096 KB Output is correct
62 Correct 1457 ms 34332 KB Output is correct
63 Correct 1489 ms 34172 KB Output is correct
64 Correct 1479 ms 34192 KB Output is correct
65 Correct 1488 ms 34168 KB Output is correct
66 Correct 1479 ms 34120 KB Output is correct
67 Correct 1481 ms 34296 KB Output is correct
68 Correct 1266 ms 22904 KB Output is correct
69 Correct 916 ms 17272 KB Output is correct
70 Correct 1 ms 384 KB Output is correct