QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#417285#8723. 乘二light_ink_dots#WA 652ms20236kbC++141.1kb2024-05-22 17:04:162024-05-22 17:04:17

Judging History

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

  • [2024-05-22 17:04:17]
  • 评测
  • 测评结果:WA
  • 用时:652ms
  • 内存:20236kb
  • [2024-05-22 17:04:16]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<set>
using namespace std;
const int mod=1e9+7;
#define int long long
int n,m,k;
int a[1000000];
multiset<int>s;
int qpow(int a,int b){
    int ret=1;
    while(b){
        if(b&1) ret=ret*a%mod;
        a=a*a%mod;b>>=1;
    }return ret;
}
int mx(){
    return *prev(s.end());
}
int mn(){
    return *s.begin();
}
int b[1000000],tot;
int32_t main(){
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i],s.insert(a[i]);
    int ans=0;
    while(mn()*2<=mx()&&k>0){
        int w=mn();
        k--;
        s.erase(s.find(w));
        s.insert(w*2);
        // cerr<<"?? "<<w*2<<endl;
    }
    // cerr<<"?? "<<k<<" "<<mn()<<" "<<mx()<<endl;
    if(k==0){
        int ans=0;
        for(int z:s) ans+=z;
        cout<<ans%mod<<'\n';
        return 0;
    }
    for(int z:s) b[++tot]=z;
    int z=k/n,tmp=k%n;
    for(int i=1;i<=tmp;i++){
        ans+=qpow(2,z+1)*b[i];
    }
    for(int i=tmp+1;i<=n;i++){
        ans+=qpow(2,z)*b[i];
    }
    ans%=mod;
    cout<<ans;
}

詳細信息

Test #1:

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

input:

3 3
7 2 1

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: 0
Accepted
time: 418ms
memory: 17100kb

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: 110ms
memory: 15048kb

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: 652ms
memory: 20144kb

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: 638ms
memory: 16584kb

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: 621ms
memory: 19708kb

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: 313ms
memory: 14988kb

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: 399ms
memory: 17068kb

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: -100
Wrong Answer
time: 640ms
memory: 20236kb

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:

-895587163

result:

wrong answer 1st numbers differ - expected: '161069543', found: '-895587163'