QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#558112 | #8783. Cherry Picking | chenyueshan# | WA | 0ms | 3816kb | C++14 | 1.2kb | 2024-09-11 14:15:22 | 2024-09-11 14:15:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define int long long
const int mod = 1e9 + 7;
const int N = 1e6 + 50;
int x[N];
void solve()
{
int n, k;
cin >> n >> k;
int mi = 10000000;
for (int i = 0; i < n; i++)
{
cin >> x[i];
mi = min(mi, x[i]);
}
string s;
cin >> s;
int min1 = 10000000000, min2 = 0;
int num = 0;
for (int i = 0; i < n - 1; i++)
{
if (s[i] == '1' && s[i + 1] == '1')
{
if (num == 0)
{
num = 2;
}
else
{
num++;
}
min1 = min(min1, x[i]);
min1 = min(min1, x[i + 1]);
}
else
{
if (num >= k)
{
min2 = max(min2, min1);
min1 = 10000000000;
num = 0;
}
}
}
if (min2 == mi)
{
cout << 0;
}
else
{
cout << min2;
}
}
signed main()
{
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
input:
5 2 1 2 3 4 5 01101
output:
2
result:
ok answer is '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
5 2 3 4 5 2 1 10101
output:
0
result:
ok answer is '0'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3784kb
input:
1 1 1 1
output:
0
result:
wrong answer expected '1', found '0'