QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#706234 | #8142. Elevator | Yaimsea# | WA | 0ms | 5912kb | C++20 | 818b | 2024-11-03 09:34:23 | 2024-11-03 09:34:24 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
long long n,m,c[500010];
pair<long long,long long> s[500010];
long long ans[500010];
inline long long lowbit(long long x)
{
return x&(-x);
}
inline void update(long long i,long long j)
{
while(i<=n)
c[i]+=j,i+=lowbit(i);
return;
}
inline long long query(long long i)
{
long long res=0;
while(i)
res+=c[i],i-=lowbit(i);
return res;
}
int main()
{
long long i,pre;
scanf("%lld %lld",&n,&m);
for(i=1;i<=n;++i)
{
scanf("%lld",&s[i].first);
s[i].second=i;
}
sort(s+1,s+n+1);
for(i=1;i<=n;++i)
{
ans[s[i].second]=(i-1)*s[i].first-pre+query(s[i].second);
pre+=s[i].first;
update(s[i].second,1);
}
for(i=1;i<=n;++i)
{
if(ans[i]>m-2)
printf("-1\n");
else
printf("%lld\n",ans[i]);
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5912kb
input:
6 20 3 8 12 6 9 9
output:
-93891902003568 -93891902003560 -93891902003541 -93891902003564 -93891902003555 -93891902003554
result:
wrong answer 1st lines differ - expected: '0', found: '-93891902003568'