QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#563848#8783. Cherry PickingcloudyWA 0ms3628kbC++202.2kb2024-09-14 16:19:352024-09-14 16:19:36

Judging History

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

  • [2024-09-14 16:19:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-09-14 16:19:35]
  • 提交

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;
        if (check(mi)) lo = hi;
        else hi = mi - 1;
    }
    cout << lo;

}

详细

Test #1:

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

input:

5 2
1 2 3 4 5
01101

output:

2

result:

ok answer is '2'

Test #2:

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

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

input:

1 1
1
1

output:

2

result:

wrong answer expected '1', found '2'