QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#655410 | #7941. Jackpot | NITUL_ | WA | 0ms | 3568kb | C++20 | 1.2kb | 2024-10-19 04:16:39 | 2024-10-19 04:16:39 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define foro(n) for(int i=0;i<int(n);i++)
#define for1(n) for(int i=1;i<=int(n);i++)
#define fup(a,n) for(int i=a;i<int(n);i++)
#define gcd __gcd
#define sz(x) (int)(x).size()
#define pb push_back
#define endl '\n'
#define F first
#define S second
#define D double
#define ld long double
const double epi = 1e-9;
const int inf = INT_MAX;
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
const int mod = 1e9 + 7;
ll lcm(ll a,ll b){
int c=a*b;
int k=gcd(a,b);
return c/k;
}
ll range_sum(ll l, ll r){//to sum a range from a to b permutation
if(l>r)return 0;
return (l+r)*(r-l+1)/2;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t=1;
cin>>t;
while(t--){
int n; cin>>n;
vector<int> v(2*n);
foro(2*n)cin>>v[i];
sort(all(v));
ll ans=0;
for(int i=0,j=n-1;i<n;i++,j--){
ans+=abs(v[i]-v[j]);
}
cout<<ans<<endl;
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3568kb
input:
3 2 42 42 42 42 1 42 69 3 1 2 3 4 5 6
output:
0 0 4
result:
wrong answer 2nd numbers differ - expected: '27', found: '0'