QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#647613 | #5137. Tower | xianyu | WA | 6ms | 3632kb | C++14 | 1.7kb | 2024-10-17 14:56:25 | 2024-10-17 14:56:26 |
Judging History
answer
#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<bitset>
#include<unordered_map>
#include<iomanip>
#include<cassert>
#include<array>
#define fi first
#define se second
#define endl '\n'
#define pb push_back
#define ep emplace_back
#define debug(x) cout<<x<<'\n'
#define RES cout<<res<<'\n'
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define me(a,x) memset(a,x,sizeof(a))
#define L(i,j,k) for(int i=(j);i<=(k);++i)
#define R(i,j,k) for(int i=(j);i>=(k);--i)
#define r23 cout<<233<<endl;return;
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<PII,int> PIII;
typedef unsigned long long ull;
const int N=1e5+5,P=131,mod=998244353;
int qmi(int a,int b){
int res=1;
while(b){
if(b&1)res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res;
}
int inv(int a,int b){
return qmi(a,b-2);
}
int a[555],b[555];
void solve(){
set<int> s;
int n,m;
cin>>n>>m;
L(i,1,n){
cin>>a[i];
int x=a[i];
while(x){
s.insert(x);
x/=2;
}
}
int res=1e18;
for(auto t:s){
L(i,1,n){
int cnt=0;
if(a[i]<=t){
cnt=t-a[i];
}else {
int x=a[i];
while(x/2>=t){
cnt++;
x/=2;
}
cnt+=min(x-t,t-x/2);
}
b[i]=cnt;
}
sort(b+1,b+1+n);
int sum=0;
L(i,1,n-m){
sum+=b[i];
}
res=min(res,sum);
}
RES;
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int T=1;
cin>>T;
while(T--){
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3632kb
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: 6ms
memory: 3596kb
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'