QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#563853#8783. Cherry PickingcloudyWA 0ms3840kbC++202.2kb2024-09-14 16:23:212024-09-14 16:23:21

Judging History

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

  • [2024-09-14 16:23:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2024-09-14 16:23:21]
  • 提交

answer

#include <bits/stdc++.h>
#define fastIO                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(nullptr)
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define mp make_pair
#define f first
#define pb push_back
#define rep(i, a, b) for (int i = a; i < b; i++)
const ll INF = 1000000000000000000;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
string stepDir = "URDL";

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '{';
  string sep;
  for (const auto &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
#ifdef DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
#define MOD 1000000007

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using max_pq = priority_queue<T>;

int main() {
  fastIO;
  cout << fixed << setprecision(10);
  int n, k;
  cin >> n >> k;
    vector<int> a(n); 
    for (int i = 0; i < n; i++) cin >> a[i];
    string s; cin >> s;

    auto check = [&](int x) {
        int cur = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] < x) {
                cur = 0;
            } else {
                if (s[i] == '1') {
                    cur++;
                    if (cur >= k) return true;
                } else cur = 0;
            }
        }
        return false;
    };

    int lo = 0, hi = 1e5 + 1;
    while (lo < hi) {
        int mi = lo + (hi - lo + 1) / 2;
        dbg(mi, check(mi));
        if (check(mi)) lo = mi;
        else hi = mi - 1;
    }
    cout << lo;

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 2
1 2 3 4 5
01101

output:

2

result:

ok answer is '2'

Test #2:

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

input:

5 2
3 4 5 2 1
10101

output:

0

result:

ok answer is '0'

Test #3:

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

input:

1 1
1
1

output:

1

result:

ok answer is '1'

Test #4:

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

input:

1 1
1
0

output:

0

result:

ok answer is '0'

Test #5:

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

input:

5 3
8 3 5 2 7
10101

output:

0

result:

wrong answer expected '5', found '0'