QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#558133#8783. Cherry PickingWendyChenWA 0ms3788kbC++201.5kb2024-09-11 14:23:112024-09-11 14:23:12

Judging History

你现在查看的是最新测评结果

  • [2024-09-11 14:23:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3788kb
  • [2024-09-11 14:23:11]
  • 提交

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 = inf, mx = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
        mi = min(mi, x[i]);
    }
    string s;
    cin >> s;
    int min1 = inf, min2 = 0;
    int num = 0;
    if (s[n - 1] == '1')
    {
        mx = x[n - 1];
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] == '1')
        {
            mx = max(mx, x[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 = inf;
                num = 0;
            }
        }
    }
    if (num != 0)
    {
        min2 = max(min2, min1);
    }
    if (k == 1 && n != 1)
    {
        cout << mx;
    }
    else 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();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3516kb

input:

5 2
1 2 3 4 5
01101

output:

2

result:

ok answer is '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3428kb

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: 3788kb

input:

1 1
1
1

output:

0

result:

wrong answer expected '1', found '0'