QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#706234#8142. ElevatorYaimsea#WA 0ms5912kbC++20818b2024-11-03 09:34:232024-11-03 09:34:24

Judging History

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

  • [2024-11-03 09:34:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5912kb
  • [2024-11-03 09:34:23]
  • 提交

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'