1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #include <cstdio> #include <algorithm> using namespace std; #define _CRT_SECURE_NO_WARNINGS int main(int argc, char** argv){ register int N, A, B, answer = 0; int a[2000], b[3000]; scanf("%d %d %d", &N, &A, &B); for (int i = 0; i < A; i++) scanf("%d",a + i); for (int i = 0; i < B; i++) scanf("%d", b + i); sort(a, a+A); if (N & 1) answer += a[--A]; N >>= 1; for (int i = 0; i < (A>>1); i++) b[B++] = a[A - (i<<1) - 1] + a[A - (i<<1) - 2]; sort(b, b + B); for (int i = 0; i < N; i++) answer += b[B - i - 1]; printf("%d", answer); return 0; }
|