QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#415717#8723. 乘二ANIG#WA 107ms9584kbC++14831b2024-05-21 09:07:052024-05-21 09:07:05

Judging History

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

  • [2024-05-21 09:07:05]
  • 评测
  • 测评结果:WA
  • 用时:107ms
  • 内存:9584kb
  • [2024-05-21 09:07:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+5,mods=1e9+7;
int p[N],n,k;
double g[N];
struct node{
	int bh;double sm;
	friend bool operator<(node a,node b){
		return a.sm>b.sm;
	}
};
priority_queue<node>q;
int pows(int a,int b){
	if(b==0)return 1;
	int res=pows(a,b>>1);
	res=res*res%mods;
	if(b&1)res=res*a%mods;
	return res;
}
signed main(){
	cin>>n>>k;
	int res=0;
	for(int i=1;i<=n;i++)cin>>p[i],g[i]=log2(p[i]),q.push({i,g[i]}),res+=p[i];
	int cnt=0;
	while(k--){
		cnt++;
		if(cnt>500000){
			int t=k/n;
			k-=t*n;
			for(int i=1;i<=n;i++)res+=(pows(2,t)-1)*p[i],res%=mods,p[i]=p[i]*pows(2,t)%mods;
		    cnt=-1e18;
		}
		int x=q.top().bh;
		q.pop();
		g[x]+=1;
		q.push({x,g[x]});
		res+=p[x];
		p[x]=p[x]*2%mods;
		res%=mods;
	}
	cout<<res;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: -100
Wrong Answer
time: 107ms
memory: 9584kb

input:

200000 1605067
366760624 67854 93901 693975 27016 1046 10808 6533158 54778 500941023 77236442 32173 10431454 2 9726 1553148 89282 411182309 494073 131299543 249904771 7906930 353 9909 3632698 29156 1917186 303 737 1189004 22 1983 263 711 4106258 2070 36704 12524642 5192 123 2061 22887 66 380 1 10153...

output:

430791911

result:

wrong answer 1st numbers differ - expected: '707034173', found: '430791911'