답안 #439008

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
439008 2021-06-29T04:09:33 Z skyberg Mountains (NOI20_mountains) C++17
77 / 100
2000 ms 5908 KB
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
long long int c[300000];
long long int mn[300000];
int t[100];
int main(){
    int n;
    cin >> n;
    long long int ans = 0;
    if(n >= 10005){
        cin >> c[0];
        t[c[0]]++;
        mn[0] = 0;
        for(int i = 1; i < n; i++){
            cin >> c[i];
            for(int j = 0; j < c[i]; j++){
                mn[i] += t[j];
            }
            t[c[i]]++;
        }
        memset(t, 0, sizeof(t[0])* 100);
        t[c[n - 1]]++;
        for(int i = n - 2; i >= 0; i--){
            long long int temp =0;
            for(int j = 0; j < c[i]; j++){
                temp += t[j];
            }
            ans += mn[i] * temp;
            t[c[i]]++;
        }
        cout << ans;
    }
    else{
        for(int i = 0; i < n; i++){
            cin >> c[i];
        }
        for(int i = 1; i < n - 1; i++){
            long long int a = 0, b = 0;
            for(int j = 0; j < i; j++){
                if(c[j] < c[i])a++;
            }
            for(int j = i + 1; j < n; j++){
                if(c[j] < c[i])b++;
            }
            ans += a * b;
        }
        cout << ans;
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 4892 KB Output is correct
2 Correct 59 ms 5472 KB Output is correct
3 Correct 62 ms 5564 KB Output is correct
4 Correct 58 ms 5444 KB Output is correct
5 Correct 59 ms 5448 KB Output is correct
6 Correct 60 ms 5484 KB Output is correct
7 Correct 66 ms 5448 KB Output is correct
8 Correct 56 ms 4420 KB Output is correct
9 Correct 56 ms 4300 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 4892 KB Output is correct
2 Correct 59 ms 5472 KB Output is correct
3 Correct 62 ms 5564 KB Output is correct
4 Correct 58 ms 5444 KB Output is correct
5 Correct 59 ms 5448 KB Output is correct
6 Correct 60 ms 5484 KB Output is correct
7 Correct 66 ms 5448 KB Output is correct
8 Correct 56 ms 4420 KB Output is correct
9 Correct 56 ms 4300 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 90 ms 5704 KB Output is correct
12 Correct 95 ms 5828 KB Output is correct
13 Correct 93 ms 5776 KB Output is correct
14 Correct 90 ms 5712 KB Output is correct
15 Correct 91 ms 5776 KB Output is correct
16 Correct 91 ms 5776 KB Output is correct
17 Correct 90 ms 5908 KB Output is correct
18 Correct 89 ms 5828 KB Output is correct
19 Correct 89 ms 5808 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 84 ms 360 KB Output is correct
12 Correct 85 ms 356 KB Output is correct
13 Correct 85 ms 360 KB Output is correct
14 Correct 88 ms 360 KB Output is correct
15 Correct 87 ms 332 KB Output is correct
16 Correct 83 ms 360 KB Output is correct
17 Correct 94 ms 356 KB Output is correct
18 Correct 86 ms 356 KB Output is correct
19 Correct 86 ms 360 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 4892 KB Output is correct
2 Correct 59 ms 5472 KB Output is correct
3 Correct 62 ms 5564 KB Output is correct
4 Correct 58 ms 5444 KB Output is correct
5 Correct 59 ms 5448 KB Output is correct
6 Correct 60 ms 5484 KB Output is correct
7 Correct 66 ms 5448 KB Output is correct
8 Correct 56 ms 4420 KB Output is correct
9 Correct 56 ms 4300 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 90 ms 5704 KB Output is correct
12 Correct 95 ms 5828 KB Output is correct
13 Correct 93 ms 5776 KB Output is correct
14 Correct 90 ms 5712 KB Output is correct
15 Correct 91 ms 5776 KB Output is correct
16 Correct 91 ms 5776 KB Output is correct
17 Correct 90 ms 5908 KB Output is correct
18 Correct 89 ms 5828 KB Output is correct
19 Correct 89 ms 5808 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Execution timed out 2075 ms 1896 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -