QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#416610#8723. 乘二chenjiaqiyAC ✓347ms6420kbC++171.8kb2024-05-22 00:13:382024-05-22 00:13:39

Judging History

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

  • [2024-05-22 00:13:39]
  • 评测
  • 测评结果:AC
  • 用时:347ms
  • 内存:6420kb
  • [2024-05-22 00:13:38]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define endl '\n'
#define all(a) a.begin(), a.end()
#define x first
#define y second
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define debug(_x) cout << #_x << '=' << _x << endl
typedef pair<int, int> PII;
const double eps = 1e-8;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

ll n, k;
ll a[N];

int qsm(int a, int k, int mod)
{
    int res = 1;
    while (k)
    {
        if (k & 1)
            res = res * a % mod;
        k >>= 1;
        a = (ll)a * a % mod;
    }
    return res;
}

void solve()
{
    ll mx = 0;
    cin >> n >> k;
    priority_queue<ll, vector<ll>, greater<ll>> q;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        q.push(a[i]);
        mx = max(mx, a[i]);
    }
    while (k)
    {
        int x = q.top();
        q.pop();
        while (k && x <= q.top())
            x *= 2, k--;
        q.push(x);
        if (q.top() >= mx)
        {
            while (k % n != 0)
            {
                k--;
                int x = q.top();
                q.pop();
                q.push(x * 2);
            }
            ll sum = 0;
            while (!q.empty())
            {
                sum += q.top();
                q.pop();
                sum %= mod;
            }
            cout << qsm(2ll, (k) / n, mod) * sum % mod << endl;
            return;
        }
    }
    ll sum = 0;
    while (!q.empty())
    {
        sum += q.top();
        q.pop();
        sum %= mod;
    }
    cout << sum << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int _ = 1;
    // cin >> _;

    while (_--)
        solve();

    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: 0
Accepted
time: 168ms
memory: 6392kb

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:

707034173

result:

ok 1 number(s): "707034173"

Test #3:

score: 0
Accepted
time: 35ms
memory: 6416kb

input:

200000 108039
13 851590697 3104 109395313 37 928 2329004 13853269 1 15 226 4785 488 2930 83250294 12228 145352832 120690 14511669 181 10740 26395301 4 1172 451394571 24571 11076 90419 5929 579583498 903729755 142027966 300157 25 20 22148 30321289 71577040 37091 1951 445549 21 96460 3491 624 764 1 48...

output:

752908968

result:

ok 1 number(s): "752908968"

Test #4:

score: 0
Accepted
time: 287ms
memory: 6420kb

input:

200000 2903290
201855332 123438 83762 1638319 17 122361 121973 17172 44 51 1 5 367822770 251 1908405 5 240290 185972 303017248 22227 193978 133159 92105 504 227 4796 1173 143 6 67736 252033016 257 876 845 16 39 9408 18 204865935 18263757 564396 213 126820 23050809 235107 1025 2169 7495 1264417 1 158...

output:

832633511

result:

ok 1 number(s): "832633511"

Test #5:

score: 0
Accepted
time: 288ms
memory: 6388kb

input:

200000 2896585
6 452 3906 198 2255433 1 801262 36414 814625805 15306728 1 323 9147 38 209 27 65213 52955210 1058270 212337 33487357 748 1192540 5474 45771272 953357 49527 59 76 12 58289305 2981 51095 235 109 14245387 460771 804 77441813 518 13278099 1032654 2 97035 13 1290 488716758 926 771025363 13...

output:

675173351

result:

ok 1 number(s): "675173351"

Test #6:

score: 0
Accepted
time: 287ms
memory: 6360kb

input:

200000 2903371
3753 232038 1596 27188889 29806557 4507 101382910 29719929 5846 126677 26420576 129855 3056030 2888725 4010747 4 12420 20002 24 237 253986 15720 2 1408 210143934 115978 457371 130799 370 6526734 11 12314003 12801660 157231514 115822 256104005 741129 3 1177403 33905648 17 125368170 232...

output:

682045332

result:

ok 1 number(s): "682045332"

Test #7:

score: 0
Accepted
time: 144ms
memory: 6420kb

input:

200000 1379432
217058486 3 323 10 162481 57177214 1678053 1 102 344174298 43456176 29791 26831 1163 2052378 38165 257 543 3078 20 155606738 371718950 2206343 91109757 52819894 226780639 1449 324614092 1 5156380 25135511 2 703379984 284865307 18 54995975 9 264 16066939 1 344513 386945818 23384664 138...

output:

724985989

result:

ok 1 number(s): "724985989"

Test #8:

score: 0
Accepted
time: 183ms
memory: 6412kb

input:

200000 1766925
435446 1 933 69620787 614953807 7697 553 166794 37 852 1838 282 131157201 91 5012 83045 53 471328 3 915357 7 1 791554250 6 237448 3688 15020 30076 2088 7 133877 5448 488942367 472 113 128774175 74422376 294698 453085 116 149183429 72768 138 66470849 129266201 4 716757134 77 2405 19168...

output:

517037208

result:

ok 1 number(s): "517037208"

Test #9:

score: 0
Accepted
time: 315ms
memory: 6396kb

input:

200000 688425072
2541 13648574 164117 7494942 2212249 200 1722 466007 43596 25893922 283753 637416551 81907530 15 1006457 1409 11096782 1 16 2240287 55407492 2377695 944 120 776859 890171856 6138 109 915 31958 95467702 922635 120 189 3 339 549450930 151077 10 3814 890391326 6509774 26584150 4560323 ...

output:

161069543

result:

ok 1 number(s): "161069543"

Test #10:

score: 0
Accepted
time: 308ms
memory: 6392kb

input:

200000 998927851
447404 375 1 259249 15 738452 14 48482 15786 159 5294 41 166 43506 594 5592115 2 10305 25591700 477288526 9849308 101 68 2545523 5930 3498 9467615 112241959 14 25057570 43765 943942 983 232 891982 86 52759548 32501 25855886 117 154417 15902 6 4722165 16 2 654438107 13308556 776 4321...

output:

489247406

result:

ok 1 number(s): "489247406"

Test #11:

score: 0
Accepted
time: 347ms
memory: 6408kb

input:

200000 1000000000
1000000000 175218 140993 186142 145504 175438 125343 47317 113162 172675 88894 166738 69275 88430 94792 78387 168170 176008 34542 105370 196430 143111 126048 129039 138331 50740 14940 126372 111378 165735 146845 177624 142741 132881 175406 148763 151038 107424 176573 26272 189812 6...

output:

22305951

result:

ok 1 number(s): "22305951"

Extra Test:

score: 0
Extra Test Passed