QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#417545 | #8723. 乘二 | UserKei | WA | 136ms | 12388kb | C++20 | 1019b | 2024-05-22 19:39:27 | 2024-05-22 19:39:28 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
using i64=long long;
const int M1=998244353;
const int M2=1000000007;
const int M3=1610612741;
using ll=long long;
using PII=pair<int,int>;
const int N=2e5+10;
const int mod=1e9+7;
int a[N];
void kei(){
int n,k;
cin>>n>>k;
map<int,int>f;
for(int i=1;i<=n;i++){
cin>>a[i];
f[a[i]]++;
}
int res{};
while(k>0){
auto [u,v]=*f.begin();
// for(auto [i,j]:f)cout<<i<<' '<<j<<endl;cout<<endl;
if(v<k){
f.erase(f.begin());
f[u*2]=v;
k-=v;
}
else{
f.erase(f.begin());
for(auto [x,y]:f)res=(res+x*y%mod)%mod;
res=(res+k*2*u%mod+(v-k)*u%mod)%mod;
break;
}
}
cout<<res<<'\n';
}
signed main(){
// srand(time(0));
cin.tie(nullptr)->ios::sync_with_stdio(false);
int tt=1;
// cin>>tt;
while(tt--)kei();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Wrong Answer
time: 136ms
memory: 12388kb
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:
85088901
result:
wrong answer 1st numbers differ - expected: '707034173', found: '85088901'