QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#622886#8783. Cherry Pickingrns_phn#WA 0ms3808kbC++141.1kb2024-10-09 08:18:372024-10-09 08:18:38

Judging History

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

  • [2024-10-09 08:18:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3808kb
  • [2024-10-09 08:18:37]
  • 提交

answer


/*
	no limit 
	** KE4 **
*/

#include<bits/stdc++.h>
using namespace std;

#define N 100010
#define ll long long
#define M 32

int a[N];

#define bit(x) (1 << (x))

struct RMQ {
    int n, v[M][N];

    void build (int *a, int sz) {
        int m; n = sz;
        for (int i = 0; i < n; i++) v[0][i] = a[i];
        for (int k = 0; (m = n - bit(k + 1)) >= 0; k++)
            for (int i = 0; i <= m; i++)
                v[k + 1][i] = min(v[k][i], v[k][i + bit(k)]);
    }

    int query (int st, int en) {
        if (st == en) return v[0][st];
        int k = 31 - __builtin_clz(en - st);
        return min(v[k][st], v[k][en - bit(k) + 1]);
    }
} R;

int main(){
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	for(int i = 0;i < n;i ++) cin >> a[i];
	string s;
	cin >> s;
	R.build(a, n);
	int cnt = 0, mn = 1e9, ans = 0;
	for(int i = 0;i < n;i ++) {
		if(s[i] == '1') cnt ++, mn = min(mn, a[i]);
		else {
			cnt = 0;
			mn = 1e9;
			continue;
		}
		if(cnt >= k) {
			int y = R.query(i - k + 1, i);
			ans = max(ans, mn);
			cnt --;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 2
1 2 3 4 5
01101

output:

2

result:

ok answer is '2'

Test #2:

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

input:

5 2
3 4 5 2 1
10101

output:

0

result:

ok answer is '0'

Test #3:

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

input:

1 1
1
1

output:

1

result:

ok answer is '1'

Test #4:

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

input:

1 1
1
0

output:

0

result:

ok answer is '0'

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3596kb

input:

5 3
8 3 5 2 7
10101

output:

0

result:

wrong answer expected '5', found '0'