QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#662032#8723. 乘二AKIOIRE 0ms3888kbC++141.0kb2024-10-20 20:11:152024-10-20 20:11:40

Judging History

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

  • [2024-10-20 20:11:40]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3888kb
  • [2024-10-20 20:11:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int power(int x,int n){
	long long prod=1;
	while(n>0){
		if(n&1)
			prod=prod*x%mod;
		x=(long long )x*x%mod;
		n>>=1;
	}
	return prod;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int n,k;
	cin>>n>>k;
	vector<int>a[31];
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		int len=x/2+1;
		a[len].push_back(x);
	}
	for(int i=1;i<=30;i++)
		sort(a[i].begin(),a[i].end());
	for(int i=1;i<30;i++){
		int t=min(k,(int)a[i].size());
		for(int j=0;j<t;j++)
			a[i][j]*=2;
		k-=t;
		if(k==0){
			long long sum=0;
			for(int j=i;j<=30;j++){
				for(int x:a[j])
					sum+=x;
			}
			cout<<sum%mod<<'\n';
			return 0;
		}
		vector<int>b(a[i].size()+a[i+1].size());
		merge(a[i].begin(),a[i].end(),a[i+1].begin(),a[i+1].end(),b.begin());
		a[i+1]=b;
	}
	int q=k/n,r=k%n;
	long long t=power(2,q);
	long long ans=0;
	for(int i=0;i<r;i++)
		ans+=a[30][i]*t*2%mod;
	for(int i=r;i<n;i++)
		ans+=a[30][i]*t%mod;
	cout<<ans%mod<<'\n';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: -100
Runtime Error

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:


result: