QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#518985#8783. Cherry PickingyjsWA 1ms8196kbC++141.9kb2024-08-14 15:03:142024-08-14 15:03:14

Judging History

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

  • [2024-08-14 15:03:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:8196kb
  • [2024-08-14 15:03:14]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#define int long long
#define pr pair<int,int>
#define mkp make_pair
#define max maxx 
using namespace std;
const int N=114514;
const int inf=0x3f3f3f3f;
int n,m,s,l,i,j,num[N];
char op[N];
vector<pr >v[N];
struct qwq
{
    int l,r,ma,frsum,basum,sum;
}a[N<<2];
inline void qwq(int &x)
{
    if(x<0)
        x=0;
}
int maxx(int a,int b)
{
    return a>b?a:b;
}
inline void pushup(int p)
{
    a[p].ma=max(max(a[p<<1].ma,a[p<<1|1].ma),a[p<<1].basum+a[p<<1|1].frsum);
    a[p].frsum=max(a[p<<1].frsum,a[p<<1].sum+a[p<<1|1].frsum);
    a[p].basum=max(a[p<<1|1].basum,a[p<<1|1].sum+a[p<<1].basum);
    // qwq(a[p].ma),qwq(a[p].frsum),qwq(a[p].basum);
    a[p].sum=a[p<<1].sum+a[p<<1|1].sum;
}
void build(int l,int r,int p)
{
    a[p].l=l;
    a[p].r=r;
    a[p].sum=a[p].ma=a[p].frsum=a[p].basum=0;
    if(l==r)
        return ;
    int mid=(l+r)>>1;
    build(l,mid,p<<1);
    build(mid+1,r,p<<1|1);
}
void change(int x,int p,int d)
{
    if(a[p].l==a[p].r)
    {
        a[p].frsum=a[p].basum=a[p].ma=a[p].sum=d;
        qwq(a[p].frsum),qwq(a[p].basum),qwq(a[p].ma);
        return ;
    }
    int mid=(a[p].l+a[p].r)>>1;
    if(x<=mid)
        change(x,p<<1,d);
    else
        change(x,p<<1|1,d);
    pushup(p);
}
signed main()
{
    // freopen("qwq.in","r",stdin);
    // freopen("a.out","w",stdout);
    int k;
    scanf("%lld%lld",&n,&k);
    for(i=1;i<=n;i++)
        scanf("%lld",&num[i]);
    scanf("%s",op+1);
    build(1,n,1);
    for(i=1;i<=n;i++)
    {
        if(op[i]=='0')
            v[num[i]].push_back(mkp(i,-inf));
        else
            v[num[i]].push_back(mkp(i,1));
    }
    for(i=n;i>=1;i--)
    {
        for(j=0;j<v[i].size();j++)
            change(v[i][j].first,1,v[i][j].second);
        // cout<<a[1].ma<<endl;
        if(a[1].ma>=k)
            break;
    }
    printf("%lld",i);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 2
1 2 3 4 5
01101

output:

2

result:

ok answer is '2'

Test #2:

score: 0
Accepted
time: 1ms
memory: 6588kb

input:

5 2
3 4 5 2 1
10101

output:

0

result:

ok answer is '0'

Test #3:

score: 0
Accepted
time: 1ms
memory: 7968kb

input:

1 1
1
1

output:

1

result:

ok answer is '1'

Test #4:

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

input:

1 1
1
0

output:

0

result:

ok answer is '0'

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 8072kb

input:

5 3
8 3 5 2 7
10101

output:

0

result:

wrong answer expected '5', found '0'