题解 | #想不出题目#

想不出题目

https://ac.nowcoder.com/acm/contest/69738/A

#include <bits/stdc++.h> using namespace std; int a[1100]; int main() { int t; cin >> t;

while( t -- )
{
    int n;
    cin >> n;
    for( int i = 1 ; i <= 2 * n ; i ++ ) cin >> a[i];
    sort(a + 1 , a + 1 + 2 * n);
    
    int s = a[n] - a[1] + a[2 * n] - a[n + 1];
    cout << s << endl;
    
    for( int i = 1 ; i <= n ; i ++ )
    {
        cout << a[i] << ' ' << a[i + n] << endl;
    }
}
return 0;

}

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务