hiho week 299 register

Ended

Participants:71

Verdict:Accepted
Score:100 / 100
Submitted:2020-03-25 17:52:05

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <cstdio>
using namespace std;
int n;
int A[100005];
long long res, c1, c3;
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i ++) {
        scanf("%d", A + i);
        if (A[i] == 3) c3 ++;
    }
    for (int i = 0; i < n; i ++) {
        if (A[i] == 3) c3 --;
        if (A[i] == 2) res = res + c3 * c1;
        if (A[i] == 1) c1 ++;
    }
    printf("%lld\n", res);
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX