답안 #224549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224549 2020-04-18T11:47:11 Z Autoratch Mountains (NOI20_mountains) C++14
24 / 100
443 ms 47988 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++)
    {
        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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 443 ms 47872 KB Output is correct
3 Correct 435 ms 47868 KB Output is correct
4 Correct 406 ms 47988 KB Output is correct
5 Correct 424 ms 47804 KB Output is correct
6 Correct 412 ms 47968 KB Output is correct
7 Correct 412 ms 47840 KB Output is correct
8 Correct 433 ms 47892 KB Output is correct
9 Correct 255 ms 29664 KB Output is correct
10 Correct 254 ms 29664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 6644 KB Output is correct
2 Correct 63 ms 7284 KB Output is correct
3 Correct 63 ms 7284 KB Output is correct
4 Correct 60 ms 7284 KB Output is correct
5 Correct 60 ms 7276 KB Output is correct
6 Correct 63 ms 7284 KB Output is correct
7 Correct 58 ms 7276 KB Output is correct
8 Correct 57 ms 7284 KB Output is correct
9 Correct 57 ms 7284 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 6644 KB Output is correct
2 Correct 63 ms 7284 KB Output is correct
3 Correct 63 ms 7284 KB Output is correct
4 Correct 60 ms 7284 KB Output is correct
5 Correct 60 ms 7276 KB Output is correct
6 Correct 63 ms 7284 KB Output is correct
7 Correct 58 ms 7276 KB Output is correct
8 Correct 57 ms 7284 KB Output is correct
9 Correct 57 ms 7284 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 82 ms 7540 KB Output is correct
12 Correct 83 ms 7532 KB Output is correct
13 Correct 85 ms 7532 KB Output is correct
14 Correct 87 ms 7540 KB Output is correct
15 Correct 82 ms 7540 KB Output is correct
16 Correct 80 ms 7540 KB Output is correct
17 Correct 79 ms 7540 KB Output is correct
18 Correct 59 ms 7540 KB Output is correct
19 Correct 65 ms 7540 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 6644 KB Output is correct
2 Correct 63 ms 7284 KB Output is correct
3 Correct 63 ms 7284 KB Output is correct
4 Correct 60 ms 7284 KB Output is correct
5 Correct 60 ms 7276 KB Output is correct
6 Correct 63 ms 7284 KB Output is correct
7 Correct 58 ms 7276 KB Output is correct
8 Correct 57 ms 7284 KB Output is correct
9 Correct 57 ms 7284 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 82 ms 7540 KB Output is correct
12 Correct 83 ms 7532 KB Output is correct
13 Correct 85 ms 7532 KB Output is correct
14 Correct 87 ms 7540 KB Output is correct
15 Correct 82 ms 7540 KB Output is correct
16 Correct 80 ms 7540 KB Output is correct
17 Correct 79 ms 7540 KB Output is correct
18 Correct 59 ms 7540 KB Output is correct
19 Correct 65 ms 7540 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 255 ms 14280 KB Output is correct
22 Correct 268 ms 14412 KB Output is correct
23 Correct 248 ms 14304 KB Output is correct
24 Correct 246 ms 14176 KB Output is correct
25 Correct 248 ms 14304 KB Output is correct
26 Correct 253 ms 14304 KB Output is correct
27 Correct 260 ms 14304 KB Output is correct
28 Correct 145 ms 14304 KB Output is correct
29 Correct 148 ms 14176 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 443 ms 47872 KB Output is correct
3 Correct 435 ms 47868 KB Output is correct
4 Correct 406 ms 47988 KB Output is correct
5 Correct 424 ms 47804 KB Output is correct
6 Correct 412 ms 47968 KB Output is correct
7 Correct 412 ms 47840 KB Output is correct
8 Correct 433 ms 47892 KB Output is correct
9 Correct 255 ms 29664 KB Output is correct
10 Correct 254 ms 29664 KB Output is correct
11 Correct 69 ms 6644 KB Output is correct
12 Correct 63 ms 7284 KB Output is correct
13 Correct 63 ms 7284 KB Output is correct
14 Correct 60 ms 7284 KB Output is correct
15 Correct 60 ms 7276 KB Output is correct
16 Correct 63 ms 7284 KB Output is correct
17 Correct 58 ms 7276 KB Output is correct
18 Correct 57 ms 7284 KB Output is correct
19 Correct 57 ms 7284 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 82 ms 7540 KB Output is correct
22 Correct 83 ms 7532 KB Output is correct
23 Correct 85 ms 7532 KB Output is correct
24 Correct 87 ms 7540 KB Output is correct
25 Correct 82 ms 7540 KB Output is correct
26 Correct 80 ms 7540 KB Output is correct
27 Correct 79 ms 7540 KB Output is correct
28 Correct 59 ms 7540 KB Output is correct
29 Correct 65 ms 7540 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 -