QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#659790#5137. TowerDINGWA 11ms3608kbC++231.3kb2024-10-19 22:05:412024-10-19 22:05:41

Judging History

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

  • [2024-10-19 22:05:41]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:3608kb
  • [2024-10-19 22:05:41]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define N 100007
using namespace std;

void solve(){
    int n,m;cin>>n>>m;
    set<int>se;
    int ac[n+1]={0};
    for(int i=0;i<n;i++){
        int x;cin>>x;
        ac[i]=x;
        while(x){
            se.insert(x);
            x>>=1;
        }
    }
    int minn=0x3f3f3f3f;
    int jjj=se.size();
    for(int i=0;i<jjj;i++){
        multiset<int>rankk;
        int mc=*se.begin();
        //cout<<mc<<" ";
        se.erase(se.begin());
        for(int j=0;j<n;j++){
            int point=0;
            int ace=ac[j];
           // cout<<"mc="<<mc<<"ace="<<ace<<endl;
            if(ace>mc){
                while(ace/2>=mc)point++,ace/=2;
                point+=min(mc-ace/2,ace-mc);
            }
            else if(ace<mc)point+=mc-ace;  
            //cout<<"point="<<" "<<point<<endl;
            rankk.insert(point);
        }int tem=0;
        for(int j=0;j<n-m;j++){
            tem+=*rankk.begin();
            //cout<<*rankk.begin()<<" ";
            rankk.erase(rankk.begin());
        }//cout<<"?"<<endl;
       // cout<<endl;
        minn=min(minn,tem);
    }//cout<<endl;
    cout<<minn<<endl;
    if(se.size())se.clear();
}
signed main(){
    fast;int t;cin>>t;while(t--){solve();} return 0;
}

详细

Test #1:

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

input:

3
2 0
2 6
5 0
1 2 3 4 5
5 3
1 2 3 4 5

output:

2
4
1

result:

ok 3 number(s): "2 4 1"

Test #2:

score: -100
Wrong Answer
time: 11ms
memory: 3492kb

input:

10
272 118
11 14 49 94 71 62 46 45 74 22 15 36 7 37 27 35 96 85 75 78 76 64 23 59 17 35 71 28 96 82 5 66 2 48 57 31 88 10 61 73 79 23 19 52 39 76 48 98 5 39 48 51 90 90 60 27 47 24 24 56 48 27 39 21 38 18 20 9 62 83 47 15 51 22 73 74 7 80 64 60 86 74 59 7 84 38 99 31 42 60 52 41 63 88 59 90 77 40 68...

output:

399
3
380
90
493
570
886
202
589
45

result:

wrong answer 1st numbers differ - expected: '454', found: '399'