QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#418652#8723. 乘二mingqian_233#WA 64ms9380kbC++141.6kb2024-05-23 15:00:292024-05-23 15:00:29

Judging History

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

  • [2024-05-23 15:00:29]
  • 评测
  • 测评结果:WA
  • 用时:64ms
  • 内存:9380kb
  • [2024-05-23 15:00:29]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
using namespace std;
const int mod = 1e9 + 7;
int f_pow(int x, int y) {
    if (y == 1) return x;
    if (y == 0) return 1;
    int t = f_pow(x, y / 2) % mod;
    if (y % 2)
        return t * t % mod * x % mod;
    else
        return t * t % mod;
}
struct node{
    int val, mi, left;
};
bool cmp1(const node x,const node y){
    return x.val < y.val;
}
bool cmp2(const node x,const node y){
    return x.left < y.left;
}
signed main() {
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
    int n, k, tot = 0;
    cin >> n >> k;
    vector<node> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].val;
        a[i].mi = log2(a[i].val);
        tot += a[i].mi;
    }
    vector<int> mult(n);  // 储存这里即将乘2的多少次方
    int ava = (tot + k) / n;
    sort(a.begin(), a.end(),cmp1);
    int m;
    for (m = n - 1; m > 0; m--) {
        ava = (tot + k) / (m + 1);
        tot -= a[m].mi;
        if (a[m].mi < ava) break;
    }
    for (int i = 0; i <= m; i++) {
        mult[i] = ava - a[i].mi;
        k -= mult[i];
    }
    sort(a.begin(), a.begin()+m+1, cmp2);
    for (int i = 0; i <= m; i++) {
        if (k == 0) break;
        mult[i]++;
        k--;
    }
    // puts("mult:");for (int i = 0; i <= m; i++) cout << mult[i] << ' ';
    int ans = 0;
    // printf("\nnums:\n");
    for (int i = 0; i < n; i++) {
        a[i].val = a[i].val * f_pow(2, mult[i]) % mod;
        // cout << a[i].val << ' ';
        ans = (ans + a[i].val) % mod;
    }
    cout << ans % mod;
    return 0;
}

详细

Test #1:

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

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: -100
Wrong Answer
time: 64ms
memory: 9380kb

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:

31501943

result:

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