QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#630231 | #8783. Cherry Picking | qianchen06# | WA | 1ms | 3628kb | C++20 | 1.4kb | 2024-10-11 17:15:29 | 2024-10-11 17:15:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, k, rating[N], cnt[N];
vector<int> pos[N];
set<int> zero, valid;
string result;
void solve()
{
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> rating[i];
cin >> result;
result = "0" + result + "0";
for (int i = n + 1; i >= 1; i--)
{
pos[rating[i]].push_back(i);
if (result[i] == '0')
{
zero.insert(i);
}
else
{
int nxt = *zero.upper_bound(i);
cnt[nxt]++;
if (cnt[nxt] >= k)
valid.insert(nxt);
}
}
int x = 0;
for (int i = 0; i <= 100000; i++)
{
for (int p : pos[i])
{
int nxt = *zero.upper_bound(p);
if (result[p] == '0')
{
zero.erase(p);
valid.erase(p);
cnt[nxt] += cnt[p];
if (cnt[nxt] >= k)
valid.insert(nxt);
}
else
{
cnt[nxt]--;
if (cnt[nxt] < k)
valid.erase(nxt);
}
}
if (valid.size())
x = i + 1;
}
cout << x << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3512kb
input:
5 2 1 2 3 4 5 01101
output:
2
result:
ok answer is '2'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
5 2 3 4 5 2 1 10101
output:
0
result:
ok answer is '0'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3628kb
input:
1 1 1 1
output:
100001
result:
wrong answer expected '1', found '100001'