QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#195132 | #2384. Tree | galen_colin# | AC ✓ | 7ms | 9972kb | C++14 | 2.7kb | 2023-10-01 01:08:21 | 2023-10-01 01:08:22 |
Judging History
answer
// comp = compile
// compr = compile & run
// in terminal, gocp goes to cp directory
#include <bits/stdc++.h>
using namespace std;
#include <bits/extc++.h>
using namespace __gnu_pbds;
using ll = int;
using ordered_set = tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>;
using pl = pair<ll, ll>;
#define f first
#define s second
ll n, m;
vector<ll> adj[105];
ll dp[105][105][105];
ll dp2[105][105][105];
ll sz[105];
ll a[105];
void dfs(ll v, ll p) {
sz[v] = 1;
vector<ll> ch;
for (ll x: adj[v]) if (x != p) {
dfs(x, v);
ch.push_back(x);
sz[v] += sz[x];
}
memset(dp2[0], 1, sizeof dp2[0]);
dp2[0][0][0] = 0;
ll s = 0;
for (ll i = 0; i < ch.size(); i++) {
ll x = ch[i];
memset(dp2[i + 1], 1, sizeof dp2[i + 1]);
for (ll a = 0; a <= s; a++) {
for (ll b = 0; b <= s; b++) {
for (ll c = 0; c <= sz[x]; c++) {
for (ll d = 0; d <= sz[x]; d++) {
ll td = (a > 0 ? b + 1 : -n) + (c > 0 ? d + 1 : -n);
ll cd = max(b, d);
dp2[i + 1][a + c][cd] = min(dp2[i + 1][a + c][cd], max(td, max(dp2[i][a][b], dp[x][c][d])));
}
}
}
}
s += sz[x];
}
memset(dp[v], 1, sizeof dp[v]);
for (ll i = 0; i <= n; i++) for (ll j = 0; j <= n; j++) {
if (i == 0) dp[v][i][j] = min(dp[v][i][j], dp2[ch.size()][i][j]);
else if (j > 0) dp[v][i][j] = min(dp[v][i][j], dp2[ch.size()][i][j - 1]);
}
// cout << v << " " << dp[v][1][1] << " " << dp[v][1][0] << " " << dp[v][2][0] << " " << dp[v][2][1] << '\n';
if (a[v] == 1) for (ll i = sz[v]; i >= 0; i--) for (ll j = 0; j <= sz[v]; j++) {
// cout << i << " " << j << " " << dp[v][i][j] << '\n';
dp[v][i + 1][j] = min(dp[v][i + 1][j], max(dp[v][i][j], j));
// cout << i << " " << j << " " << dp[v][i + 1][j] << '\n';
}
// cout << "V " << v << " " << a[v] << '\n';
// for (ll i = 0; i <= sz[v]; i++) {
// for (ll j = 0; j <= sz[v]; j++) {
// cout << i << " " << j << " " << dp[v][i][j] << '\n';
// }
// }
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (ll i = 0; i < n; i++) cin >> a[i];
for (ll i = 0; i < n - 1; i++) {
ll x, y;
cin >> x >> y;
--x; --y;
adj[x].push_back(y);
adj[y].push_back(x);
}
dfs(0, -1);
ll ans = 1e9;
for (ll i = 0; i <= n; i++) ans = min(ans, dp[0][m][i]);
cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5632kb
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: 0ms
memory: 5600kb
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: 1ms
memory: 5720kb
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: 1ms
memory: 5592kb
input:
2 2 1 1 2 1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 1ms
memory: 7668kb
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: 1ms
memory: 5644kb
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: 1ms
memory: 5660kb
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: 1ms
memory: 5720kb
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: 5648kb
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: 5608kb
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: 1ms
memory: 5640kb
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: 1ms
memory: 7768kb
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: 1ms
memory: 7700kb
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: 1ms
memory: 7740kb
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: 2ms
memory: 7780kb
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: 7744kb
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: 3ms
memory: 7764kb
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: 2ms
memory: 7812kb
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: 7776kb
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: 6ms
memory: 9724kb
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: 2ms
memory: 9740kb
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: 5ms
memory: 8432kb
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: 2ms
memory: 8688kb
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: 5ms
memory: 9368kb
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: 5ms
memory: 9328kb
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: 5ms
memory: 8028kb
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: 3ms
memory: 9484kb
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: 2ms
memory: 8568kb
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: 6ms
memory: 9972kb
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: 6ms
memory: 8684kb
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: 6ms
memory: 7956kb
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: 3ms
memory: 8376kb
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: 3ms
memory: 9780kb
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: 6ms
memory: 9720kb
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: 6ms
memory: 9128kb
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: 3ms
memory: 8048kb
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: 7ms
memory: 9556kb
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: 1ms
memory: 5552kb
input:
1 1 1
output:
0
result:
ok single line: '0'
Test #39:
score: 0
Accepted
time: 1ms
memory: 5716kb
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: 1ms
memory: 5584kb
input:
5 5 1 1 1 1 1 1 2 2 3 4 3 5 3
output:
3
result:
ok single line: '3'