QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#416424#8723. 乘二Afterlife#WA 0ms3500kbC++201.2kb2024-05-21 20:30:292024-05-21 20:30:30

Judging History

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

  • [2024-05-21 20:30:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3500kb
  • [2024-05-21 20:30:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n , k;
const int mod = 1e9 + 7;
int a[200005];
typedef long long ll;
vector<int> op;
int fpow(int a,int b) {
    int ans = 1;
    while(b) {
        if(b & 1) ans = 1LL * ans * a %mod;
        a = 1LL * a * a %mod;b >>= 1;
    }
    return ans;
}
int main() {
    ios::sync_with_stdio(false) ; cin.tie(0) ;
    cin >> n >> k;
    for(int i = 1;i <= n;i++) cin >> a[i];
    sort(a + 1 , a + n + 1);
    multiset<ll> st;
    for(int i = 1;i <= n;i++) st.insert(a[i]);
    auto chk = [&]() {
        auto it = st.begin() ; 
        auto it2 = st.end() ; it2--;
        return (*it) * 2 > (*it2) ;
    };
    while(!chk() && k) {
        auto it = st.begin() ; 
        ll x = (*it) * 2;
        st.erase(it) ; st.insert(x) ;
        k--;
    }
    auto sum = [&]() {
        int ans = 0;
        for(auto x : st) ans = (ans + x) % mod;
        return ans;
    };
    if(!k) {
        cout << sum() << '\n';
    }
    int mul = k / n;
    int d = k % n;
    while(d--) {
        auto it = st.begin() ; 
        ll x = (*it) * 2;
        st.erase(it) ; st.insert(x) ;
    }
    int ans = sum() ;
    ans = 1LL * ans * fpow(2 , mul) % mod;
    cout << ans << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3500kb

input:

3 3
7 2 1

output:

15
15

result:

wrong answer Output contains longer sequence [length = 2], but answer contains 1 elements