QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#417586 | #8723. 乘二 | UserKei | WA | 150ms | 15768kb | C++20 | 1.9kb | 2024-05-22 19:54:19 | 2024-05-22 19:54:19 |
Judging History
answer
#include<bits/stdc++.h>
// #define int long long
#define int __int128
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>;
namespace __Kei128{
using i128=__int128;
i128 abs(const i128 &x){
return x>0?x:-x;
}
auto &operator>>(istream &it,i128 &j){
string val;
it>>val;
reverse(val.begin(), val.end());
i64 ans=0;
bool f=0;
char c=val.back();
val.pop_back();
for(;c<'0'||c>'9';c=val.back(),val.pop_back()){
if(c=='-'){
f=1;
}
}
for(;c>='0'&&c<='9';c=val.back(),val.pop_back()){
ans=ans*10+c-'0';
}
j=f?-ans:ans;
return it;
}
auto &operator<<(ostream &os, const i128 &j) {
string ans;
function<void(i128)>write=[&](i128 x) {
if(x<0)ans+='-',x=-x;
if(x>9)write(x/10);
ans+=x%10+'0';
};
write(j);
return os<<ans;
}
}using namespace __Kei128;
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=0;
while(k>0){
auto [u,v]=*f.begin();
// for(auto [i,j]:f)cout<<i<<' '<<j<<endl;cout<<endl;
f.erase(f.begin());
if(v<k){
f[u*2]=v;
k-=v;
}
else{
for(auto [x,y]:f)res=(res+x*y%mod)%mod;
res=(res+k*2%mod*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: 3876kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Wrong Answer
time: 150ms
memory: 15768kb
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'