求助75pts WA#8,9,10,11,13
查看原帖
求助75pts WA#8,9,10,11,13
1385606
Yun_Mo_s5_013楼主2024/10/19 17:21
#include<bits/stdc++.h>
using namespace std;
#define ll long long

const int mod=92084931;
int n,m;
int ans=0;
int nums[114514];
int anum[114514];
int snum[114514];
int tmp[114514];

void merge(int l,int r){
	if(l>=r) return;
	int mid=(r+l)>>1;
	merge(l,mid);
	merge(mid+1,r);*/
	int pos1=l,pos2=mid+1,pos_t=l;
	while(pos1<=mid&&pos2<=r){
		if(snum[pos1]<snum[pos2]){
			tmp[pos_t++]=snum[pos2++];
			//ans+=mid-pos1+1;
			//ans%=mod;
			ans=(ans%mod+(mid-pos1+1)%mod)%mod;
		} else if(snum[pos1]>=snum[pos2]){
			tmp[pos_t++] = snum[pos1++];
		}
	}
	while(pos1<=mid) tmp[pos_t++]=snum[pos1++];
	while(pos2<=r) tmp[pos_t++]=snum[pos2++];
	for(int i=l;i<=r;i++) snum[i]=tmp[i];
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d",&nums[i]);
		anum[i]=nums[i]-m;
		snum[i]=anum[i]+snum[i-1];
	}
	merge(0,n);
	printf("%d",ans);
	return 0;
}

2024/10/19 17:21
加载中...