QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#415717 | #8723. 乘二 | ANIG# | WA | 107ms | 9584kb | C++14 | 831b | 2024-05-21 09:07:05 | 2024-05-21 09:07:05 |
Judging History
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'