QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#602564#8723. 乘二ITC_TL#TL 1ms5692kbC++201.3kb2024-10-01 10:47:172024-10-01 10:47:19

Judging History

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

  • [2024-10-01 10:47:19]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:5692kb
  • [2024-10-01 10:47:17]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fore(i, l, r) for (register int i = (int)l; i <= (int)r; i++)
#define ford(i, r, l) for (register int i = (int)r; i >= (int)l; i--)
const int MAXN = 2123456LL;
ll T, n, k, a[MAXN];
ll ans[MAXN];
ll mod = 1e9 + 7;
priority_queue<ll, vector<ll>, greater<ll>> q;
ll qm(ll x, ll y)
{
    ll ret = 1;
    while (y)
    {
        if (y & 1)
            ret = ret * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ret;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll sum1 = 0;
    cin >> n >> k;
    fore(i, 1, n)
    {
        cin >> a[i];
        sum1 += a[i];
        q.push(a[i]);
    }
    sort(a + 1, a + 1 + n);
    ll cnt = 0;
    while (a[1] * 2 < a[n])
    {
        if (cnt == k)
            break;
        sum1 += a[1];
        a[1] *= 2;
        sum1 %= mod;
        cnt++;
        sort(a + 1, a + 1 + n);
    }
    if (cnt == k)
        cout << sum1 << endl;
    else
    {
        k -= cnt;
        ll tmp = k % n, zh = k / n;
        ll gg = 0;
        fore(i, 1, tmp) gg += a[i] * qm(2, zh) % mod;
        sum1 = sum1 * qm(2, zh) % mod;
        sum1 = sum1 + gg;
        sum1 %= mod;
        cout << sum1 << endl;
    }
    return 0;
}

詳細信息

Test #1:

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

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: -100
Time Limit Exceeded

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:


result: