Comet OJ - Contest #3
当天晚上多开了几场比赛
所以这个只a了a题就没管了
A题 比赛
签到题 水题 模拟一下就可以了
AC代码:
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; bool cmp(ll a, ll b){ return a > b; } ll n, k; ll a[505]; ll b[125000]; ll cnt = 0; ll ans = 0; int main(){ memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); cin>>n>>k; for (int i = 0; i < n; i++) cin>>a[i]; for (int i = 0; i < n; i++){ for (int j = i + 1; j < n; j++){ b[cnt] = a[i] + a[j]; cnt++; } } sort(b, b + 124750, cmp); for (int i = 0; i < k; i++) ans += b[i]; cout<<ans<<endl; return 0; }