QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#672945 | #2384. Tree | Yarema# | AC ✓ | 1ms | 3776kb | C++14 | 1.8kb | 2024-10-24 19:59:21 | 2024-10-24 19:59:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;
const int N = 147;
const int INF = 1e9 + 47;
VI g[N];
int c[N];
int dp[N][N];
int n;
void updMax(int& a, int b)
{
a = max(a, b);
}
void dfs(int v, int p, int dis)
{
//cerr << v << ' ' << p << '\n';
for (auto to : g[v])
if (to != p)
dfs(to, v, dis);
dp[v][0] = c[v];
FOR (mx, 0, dis - 1)
{
int sum = 0;
int ds = min(mx, dis - mx - 2);
for (auto to : g[v])
if (to != p)
sum += dp[to][ds];
for (auto to : g[v])
if (to != p)
updMax(dp[v][mx + 1], dp[to][mx] - dp[to][ds] + sum + c[v]);
}
for (auto to : g[v])
if (to != p)
updMax(dp[v][dis], dp[to][dis - 1] + c[v]);
FOR (ds, 0, dis)
updMax(dp[v][ds + 1], dp[v][ds]);
}
int f(int dis)
{
FOR (i, 0, N) FOR (j, 0, N) dp[i][j] = 0;
dfs(0, 0, dis);
//FOR (i, 0, n)
//{
// FOR (ds, 0, dis + 1)
// cerr << dp[i][ds] << ' ';
// cerr << '\n';
//}
int ans = 0;
FOR (i, 0, n)
updMax(ans, dp[i][dis]);
return ans;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int k;
cin >> n >> k;
FOR (i, 0, n) cin >> c[i];
FOR (i, 0, n - 1)
{
int a, b;
cin >> a >> b;
a--, b--;
g[a].PB(b);
g[b].PB(a);
}
//cerr << f(4) << '\n';
//
//return 0;
int l = -1, r = n;
while (l + 1 < r)
{
int mid = (l + r) / 2;
if (f(mid) >= k)
r = mid;
else
l = mid;
}
cout << r << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3640kb
input:
6 3 1 1 0 1 1 1 1 2 1 3 1 4 3 5 3 6
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
9 4 1 0 1 0 1 0 0 1 1 1 2 2 4 2 3 4 5 1 6 6 7 6 8 7 9
output:
5
result:
ok single line: '5'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
7 2 0 1 0 1 0 1 0 3 6 1 3 5 3 7 1 4 5 2 7
output:
3
result:
ok single line: '3'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
2 2 1 1 2 1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
6 1 0 1 1 0 1 1 3 5 6 3 4 5 2 6 1 3
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
8 8 1 1 1 1 1 1 1 1 3 1 5 3 6 5 8 5 2 1 7 3 4 6
output:
5
result:
ok single line: '5'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
9 3 0 1 1 1 1 0 0 1 1 4 8 7 8 5 8 1 7 3 7 2 3 9 7 6 3
output:
2
result:
ok single line: '2'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
5 2 1 0 1 1 1 1 3 4 1 2 4 5 2
output:
1
result:
ok single line: '1'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
6 3 0 1 1 0 1 1 3 2 5 3 6 5 4 2 1 5
output:
2
result:
ok single line: '2'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
10 3 0 0 1 0 0 1 1 0 1 1 5 7 4 5 8 4 2 8 3 2 10 3 1 10 9 1 6 9
output:
3
result:
ok single line: '3'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
12 2 0 0 0 0 0 1 0 1 0 0 0 0 11 7 10 7 12 10 2 12 3 2 9 10 5 3 4 12 1 5 6 12 8 2
output:
3
result:
ok single line: '3'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
14 6 1 1 1 0 1 0 1 0 1 1 0 1 1 1 3 8 14 3 6 14 12 6 10 12 7 10 5 7 9 5 11 9 1 10 4 11 13 8 2 7
output:
3
result:
ok single line: '3'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
30 6 1 0 1 1 1 0 0 1 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 11 28 17 11 6 17 16 6 1 16 14 1 29 14 10 29 25 16 24 10 7 6 19 17 26 7 9 29 5 28 15 28 21 15 4 7 20 15 12 11 18 25 27 12 3 1 8 18 30 27 23 6 2 25 13 3 22 9
output:
6
result:
ok single line: '6'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
32 10 0 1 1 0 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 1 1 1 0 0 0 0 0 0 1 1 1 23 27 30 23 31 30 25 31 16 25 10 16 24 10 26 24 6 26 4 6 28 4 17 28 7 17 20 7 15 20 21 15 13 21 9 13 14 9 22 27 5 26 1 10 11 25 12 26 32 24 8 31 18 27 19 23 2 7 3 14 29 3
output:
7
result:
ok single line: '7'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
50 20 1 1 0 0 1 1 0 1 1 1 0 1 1 1 0 0 1 1 0 1 1 1 1 1 1 0 0 0 1 0 0 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 0 0 1 0 32 23 26 32 36 26 7 36 24 7 22 24 40 22 49 40 35 49 41 35 46 41 48 46 30 48 10 30 12 10 2 12 31 2 4 31 19 4 17 7 45 17 5 45 34 5 29 34 33 29 42 33 9 42 20 9 8 20 43 8 14 43 13 14 16 13 47 16 27 ...
output:
16
result:
ok single line: '16'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
60 8 0 0 0 1 1 1 0 0 1 0 0 1 1 0 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 1 1 0 0 0 1 1 1 1 0 1 1 1 1 49 55 6 49 60 6 45 60 11 45 1 11 9 1 35 9 15 35 33 45 14 33 30 14 12 30 16 12 38 16 28 38 23 28 43 23 22 43 48 45 7 48 32 7 44 32 59 44 25 59 29 25 39 29 27 39 20 27 57 30 21 ...
output:
4
result:
ok single line: '4'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
70 40 1 1 1 1 1 1 1 0 1 1 1 0 0 0 0 1 1 0 1 1 1 1 1 0 1 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 1 1 1 0 0 1 1 0 1 0 1 0 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 67 6 45 67 61 45 58 61 19 58 51 19 7 51 21 7 15 21 28 15 22 28 69 22 27 69 55 27 52 55 4 52 3 4 36 3 49 36 16 15 40 16 17 40 37 17 66 37 24 66 14 24 23 14...
output:
27
result:
ok single line: '27'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
70 10 1 1 1 1 1 1 1 0 1 1 1 0 0 0 0 1 1 0 1 1 1 1 1 0 1 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 1 1 1 0 0 1 1 0 1 0 1 0 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 67 6 45 67 61 45 58 61 19 58 51 19 7 51 21 7 15 21 28 15 22 28 69 22 27 69 55 27 52 55 4 52 3 4 36 3 49 36 16 15 40 16 17 40 37 17 66 37 24 66 14 24 23 14...
output:
5
result:
ok single line: '5'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
70 25 1 1 1 1 1 1 1 0 1 1 1 0 0 0 0 1 1 0 1 1 1 1 1 0 1 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 1 1 1 0 0 1 1 0 1 0 1 0 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 67 6 45 67 61 45 58 61 19 58 51 19 7 51 21 7 15 21 28 15 22 28 69 22 27 69 55 27 52 55 4 52 3 4 36 3 49 36 16 15 40 16 17 40 37 17 66 37 24 66 14 24 23 14...
output:
15
result:
ok single line: '15'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
80 15 0 0 0 1 0 1 0 0 0 1 0 0 0 0 1 1 1 1 0 0 0 1 0 0 1 0 0 0 1 1 1 0 1 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 61 13 45 61 47 45 44 47 78 44 5 78 18 5 35 18 60 35 58 60 26 58 24 26 74 24 38 74 65 38 7 65 69 7 27 69 29 27 6 29 50 6 15 50 70 15 73...
output:
16
result:
ok single line: '16'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
80 3 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 28 49 4 28 39 4 9 39 54 9 2 54 74 2 30 74 52 30 71 52 12 71 67 12 77 67 76 77 25 76 63 25 18 63 72 18 46 72 66 52 62 66 35 62 48 35 29 ...
output:
4
result:
ok single line: '4'
Test #22:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
80 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 28 49 4 28 39 4 9 39 54 9 2 54 74 2 30 74 52 30 71 52 12 71 67 12 77 67 76 77 25 76 63 25 18 63 72 18 46 72 66 52 62 66 35 62 48 35 29...
output:
12
result:
ok single line: '12'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
80 5 1 0 0 1 0 0 0 1 1 1 1 0 0 1 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 1 0 1 1 1 1 0 0 0 0 0 0 0 1 1 1 0 0 1 1 0 0 1 1 0 0 0 0 0 1 1 1 0 1 0 1 0 1 1 1 1 1 0 1 1 0 1 0 1 0 0 64 18 62 64 32 62 57 32 17 57 35 17 10 35 60 10 21 60 66 21 28 66 3 28 74 3 54 74 36 54 39 36 69 39 59 69 22 59 26 21 29 26 65 29 23 65...
output:
3
result:
ok single line: '3'
Test #24:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
100 5 0 1 1 0 0 0 1 0 0 0 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 0 0 1 1 0 0 0 1 1 1 1 0 1 1 1 1 1 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 1 1 0 0 0 1 1 0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 1 73 62 94 73 91 94 47 91 76 47 7 76 98 7 28 98 87 28 15 87 85 15 11 85 54 11 77 54 31 77 81 31 ...
output:
3
result:
ok single line: '3'
Test #25:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
100 50 0 1 1 0 0 0 1 0 0 0 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 0 0 1 1 0 0 0 1 1 1 1 0 1 1 1 1 1 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 1 1 0 0 0 1 1 0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 1 73 62 94 73 91 94 47 91 76 47 7 76 98 7 28 98 87 28 15 87 85 15 11 85 54 11 77 54 31 77 81 31...
output:
58
result:
ok single line: '58'
Test #26:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
100 100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 73 62 94 73 91 94 47 91 76 47 7 76 98 7 28 98 87 28 15 87 85 15 11 85 54 11 77 54 31 77 81 3...
output:
60
result:
ok single line: '60'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 73 62 94 73 91 94 47 91 76 47 7 76 98 7 28 98 87 28 15 87 85 15 11 85 54 11 77 54 31 77 81 31 ...
output:
0
result:
ok single line: '0'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
100 50 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 73 62 94 73 91 94 47 91 76 47 7 76 98 7 28 98 87 28 15 87 85 15 11 85 54 11 77 54 31 77 81 31...
output:
24
result:
ok single line: '24'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
100 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 73 62 94 73 91 94 47 91 76 47 7 76 98 7 28 98 87 28 15 87 85 15 11 85 54 11 77 54 31 77 81 31...
output:
5
result:
ok single line: '5'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
100 10 1 0 1 1 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 1 0 1 1 0 0 0 1 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 0 1 0 1 1 0 20 38 89 20 50 89 47 50 10 47 73 10 42 73 61 42 15 61 53 15 21 53 19 21 37 19 35 37 83 35 91 ...
output:
6
result:
ok single line: '6'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
100 7 1 0 1 1 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 1 0 1 1 0 0 0 1 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 0 1 0 1 1 0 20 38 89 20 50 89 47 50 10 47 73 10 42 73 61 42 15 61 53 15 21 53 19 21 37 19 35 37 83 35 91 8...
output:
4
result:
ok single line: '4'
Test #32:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
100 65 1 0 1 1 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 1 0 1 1 0 0 0 1 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 0 1 0 1 1 0 20 38 89 20 50 89 47 50 10 47 73 10 42 73 61 42 15 61 53 15 21 53 19 21 37 19 35 37 83 35 91 ...
output:
44
result:
ok single line: '44'
Test #33:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
100 43 1 0 1 1 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 1 0 1 1 0 0 0 1 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 0 1 0 1 1 0 20 38 89 20 50 89 47 50 10 47 73 10 42 73 61 42 15 61 53 15 21 53 19 21 37 19 35 37 83 35 91 ...
output:
29
result:
ok single line: '29'
Test #34:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
100 43 1 0 1 0 0 1 0 1 1 1 1 0 0 0 1 1 0 1 0 0 0 1 1 0 0 1 1 1 0 1 0 0 0 0 0 1 1 1 1 0 0 1 0 0 0 0 0 0 1 1 1 0 0 0 1 1 0 0 1 1 0 1 0 1 1 0 0 0 1 1 1 1 0 1 0 0 0 1 0 1 0 1 1 1 1 1 0 1 1 1 1 0 1 1 0 0 0 0 1 0 20 38 89 20 50 89 47 50 10 47 73 10 42 73 61 42 15 61 53 15 21 53 19 21 37 19 35 37 83 35 91 ...
output:
37
result:
ok single line: '37'
Test #35:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
100 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 20 38 89 20 50 89 47 50 10 47 73 10 42 73 61 42 15 61 53 15 21 53 19 21 37 19 35 37 83 35 91 8...
output:
1
result:
ok single line: '1'
Test #36:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
100 2 1 1 1 1 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 0 1 1 0 20 38 89 20 50 89 47 50 10 47 73 10 42 73 61 42 15 61 53 15 21 53 19 21 37 19 35 37 83 35 91 8...
output:
1
result:
ok single line: '1'
Test #37:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
100 16 0 1 1 0 0 1 1 1 0 0 1 0 1 1 0 1 1 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 1 0 1 1 0 0 1 0 0 0 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 1 0 0 0 0 1 0 1 0 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 0 0 0 0 1 0 1 1 1 1 0 1 1 1 1 0 0 1 0 72 62 59 72 91 59 47 91 76 47 50 76 98 50 28 98 87 28 15 87 82 15 11 82 100 11 93 100 86 93 9...
output:
10
result:
ok single line: '10'
Test #38:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
1 1 1
output:
0
result:
ok single line: '0'
Test #39:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
5 1 0 0 1 0 0 1 2 2 3 4 1 5 3
output:
0
result:
ok single line: '0'
Test #40:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
5 5 1 1 1 1 1 1 2 2 3 4 3 5 3
output:
3
result:
ok single line: '3'