QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#644094 | #8781. Element-Wise Comparison | liujunyi123 | WA | 1ms | 5936kb | C++14 | 614b | 2024-10-16 10:52:28 | 2024-10-16 10:52:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=50005;
int n,m,a[N],id[N];
long long ans;
bitset<N> b[N],s[N],tmp,sum,res;
bool cmp(int x,int y){return a[x]>a[y];}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%d",&a[i]),id[i]=i;
sort(id+1,id+n+1,cmp);
for(int i=1;i<=n;i++){
b[id[i]]=tmp>>id[i];
tmp[id[i]]=1;
}
for(int i=m;i<=n;i+=m){
int l=i-m+1,r=min(n,i+m);
s[0]=sum=tmp;
for(int j=i+1;j<=r;j++)s[j-i]=s[j-i-1]&b[j];
for(int j=i;j>=l;j--){
sum&=b[j];
res=sum&s[j-i+1];
ans+=res.count();
}
}
printf("%lld\n",ans);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5936kb
input:
5 3 5 2 1 3 4
output:
2
result:
wrong answer expected '0', found '2'