QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#423911#8723. 乘二aurorawhiteseaWA 49ms4716kbC++201.2kb2024-05-28 19:08:292024-05-28 19:08:29

Judging History

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

  • [2024-05-28 19:08:29]
  • 评测
  • 测评结果:WA
  • 用时:49ms
  • 内存:4716kb
  • [2024-05-28 19:08:29]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const long long MOD = 1e9 + 7;

int main() {
    int n;
    long long k;
    cin >> n >> k;
    vector<long long> a(n);
    
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    
  
    long long totalSum = 0;
    for (int i = 0; i < n; ++i) {
        totalSum += a[i];
    }
    
  
    for (int i = 0; i < n && k > 0; ++i) {
      
        long long nextVal = (i < n - 1) ? a[i + 1] : a[i] * 2;
        long long numOps = min(k, (nextVal - a[i]) / a[i] * (i + 1));
        
     
        if (numOps > 0) {
            totalSum += a[i] * numOps;
            k -= numOps;
            for (int j = 0; j <= i; ++j) {
                a[j] *= 2;
            }
        }
    }
    
 
    if (k > 0) {
        sort(a.begin(), a.end());
        a[0] *= (1LL << (k / n));
        for (int i = 0; i < k % n; ++i) {
            a[i] *= 2;
        }
    }

    long long result = 0;
    for (int i = 0; i < n; ++i) {
        result = (result + a[i]) % MOD;
    }
    
    cout << result << endl;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3560kb

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: -100
Wrong Answer
time: 49ms
memory: 4716kb

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:

520805

result:

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