QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#416423#8723. 乘二Afterlife#WA 138ms9960kbC++201.2kb2024-05-21 20:28:372024-05-21 20:28:39

Judging History

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

  • [2024-05-21 20:28:39]
  • 评测
  • 测评结果:WA
  • 用时:138ms
  • 内存:9960kb
  • [2024-05-21 20:28:37]
  • 提交

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);
    set<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';
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3556kb

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: -100
Wrong Answer
time: 138ms
memory: 9960kb

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:

578362844

result:

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