QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#563848 | #8783. Cherry Picking | cloudy | WA | 0ms | 3628kb | C++20 | 2.2kb | 2024-09-14 16:19:35 | 2024-09-14 16:19:36 |
Judging History
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'