QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#416407#8723. 乘二yzhangWA 21ms5272kbC++141.6kb2024-05-21 19:59:222024-05-21 19:59:24

Judging History

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

  • [2024-05-21 19:59:24]
  • 评测
  • 测评结果:WA
  • 用时:21ms
  • 内存:5272kb
  • [2024-05-21 19:59:22]
  • 提交

answer

#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,k,a[200005],f[200005],ans;
int pw(int a,int b){
    int res=1;
    while(b){
        if(b&1) res=1ll*res*a%mod;
        a=1ll*a*a%mod,b>>=1;
    }
    return res;
}
void sol(){
    cin>>n>>k;
    for(int i=1;i<=n;++i) cin>>a[i];
    sort(a+1,a+1+n);
    ans=0;
    for(int i=1;i<=n;++i){
        int ct=0;
        if(i!=n){
            // while(1ll*v*2<=a[i+1]) v<<=1,++ct;
            ct=int(log(a[i+1]))-int(log(a[i]));
        }else   
            ct=1;
        // cerr<<k<<" "<<ct<<" "<<i<<endl;
        if(k>=ct*i&&i!=n){
            k-=ct*i;
            f[i]+=ct;
        }else{
            if(i!=n){
                f[i]+=k/i;
                for(int j=n-1;j>=1;--j) f[j]+=f[j+1];
                for(int j=1;j<=n;++j) a[j]=1ll*a[j]*pw(2,f[j]);
                sort(a+1,a+1+n);
                for(int j=1;j<=n;++j) ans=(0ll+ans+1ll*a[j]*(1+(j<=k%i)))%mod;
                cout<<ans<<'\n';
                return;
            }else{
                for(int j=n-1;j>=1;--j) f[j]+=f[j+1];
                for(int j=1;j<=n;++j) a[j]=1ll*a[j]*pw(2,f[j]);
                sort(a+1,a+1+n);
                for(int j=1;j<=n;++j) ans=(0ll+ans+1ll*a[j]*(1+(j<=k%i)%mod*pw(2,k/i)))%mod;
                cout<<ans<<'\n';
                return;
            }
        }
    }
    // for(int i=1;i<=n;++i) cerr<<f[i]<<" \n"[i==n];
    // for(int i=1;i<=n;++i){
    //     ans=(0ll+ans+1ll*a[i]*pw(2,f[i]))%mod;
    // }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    sol();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3784kb

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: -100
Wrong Answer
time: 21ms
memory: 5272kb

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:

111903978

result:

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