『agc 012a』atcoder group contest Solution

Time limit : 2sec / Memory limit : 256MB

题意:给$3N$个数,$3​$个一组,我们取每个组第二大的数出来相加,问最大能够是多少

还是…还是弄个door吧。。

door♂

Solution

排序,取$2,4,6,8dots$就行

Code:

Click to show/hide the code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

using namespace std;
#define ll long long
ll sum = 0;
ll a[3 * 123456];
bool (ll x, ll y)
{
return x > y;
}
int n;
inline void _read(int &x)
{
x = 0;
char t = getchar();
while (!isdigit(t)) t = getchar();
while (isdigit(t))
{
x = x * 10 + t - '0';
t = getchar();
}
}
inline void _read(ll &x)
{
x = 0;
char t = getchar();
while (!isdigit(t)) t = getchar();
while (isdigit(t))
{
x = x * 10 + t - '0';
t = getchar();
}
}
int main()
{
_read(n);
for (int i = 1; i <= 3 * n; i++) _read(a[i]);
int i = 2;
sort(a + 1, a + 1 + 3 * n, cmd);
while (n--)
{
sum += a[i];
i += 2;
}
printf("%lld", sum);
return 0;
}