MSBOP 2015 Round3 register

Ended

Participants:978

Verdict:AC | AC
Submitted:2015-05-09 15:14:24

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
23
24
25
26
27
28
29
30
31
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 100010;
const int C = 21;
int n, k;
ll cnt[C][C], dp[1 << C];
int a[N], sum[N][C];
void init() {
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    memset(sum, 0, sizeof(sum));
    memset(cnt, 0, sizeof(cnt));
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= k; ++j)
            sum[i][j] = sum[i - 1][j] + (a[i] == j);
    for(int j = 1; j <= n; ++j)
        for(int i = 1; i <= k; ++i)
            cnt[a[j]][i] += sum[j][i];
}
inline void get_min(ll &x, ll y){
    if(x < y) x = y;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX