Submission #63550932
Source Code Expand
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
long long calculateMaxSum(vector<long long> black, vector<long long> white) {
sort(black.rbegin(), black.rend());
sort(white.rbegin(), white.rend());
long long maxSum = 0;
for (int i = 0; i <= (int)black.size(); ++i) {
long long sumBlack = accumulate(black.begin(), black.begin() + i, 0LL);
int maxWhiteCount = min(i, (int)white.size());
long long sumWhite = accumulate(white.begin(), white.begin() + maxWhiteCount, 0LL);
maxSum = max(maxSum, sumBlack + sumWhite);
}
return maxSum;
}
int main() {
int N, M;
cin >> N >> M;
vector<long long> black(N);
vector<long long> white(M);
for (int i = 0; i < N; ++i) {
cin >> black[i];
}
for (int i = 0; i < M; ++i) {
cin >> white[i];
}
long long result = calculateMaxSum(black, white);
cout << result << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Buy Balls |
| User | yyyyt |
| Language | C++ 20 (gcc 12.2) |
| Score | 0 |
| Code Size | 1023 Byte |
| Status | WA |
| Exec Time | 2211 ms |
| Memory | 9700 KiB |
Judge Result
| Set Name | Sample | All | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 300 | ||||||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt, 01_test_37.txt, 01_test_38.txt, 01_test_39.txt, 01_test_40.txt, 01_test_41.txt, 01_test_42.txt, 01_test_43.txt, 01_test_44.txt, 01_test_45.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | WA | 1 ms | 3480 KiB |
| 00_sample_01.txt | AC | 1 ms | 3528 KiB |
| 00_sample_02.txt | AC | 1 ms | 3408 KiB |
| 01_test_00.txt | WA | 1 ms | 3492 KiB |
| 01_test_01.txt | WA | 1 ms | 3544 KiB |
| 01_test_02.txt | WA | 1 ms | 3532 KiB |
| 01_test_03.txt | TLE | 2207 ms | 6552 KiB |
| 01_test_04.txt | TLE | 2210 ms | 5508 KiB |
| 01_test_05.txt | TLE | 2207 ms | 5264 KiB |
| 01_test_06.txt | TLE | 2211 ms | 9548 KiB |
| 01_test_07.txt | TLE | 2208 ms | 9508 KiB |
| 01_test_08.txt | TLE | 2208 ms | 9464 KiB |
| 01_test_09.txt | TLE | 2208 ms | 9564 KiB |
| 01_test_10.txt | TLE | 2208 ms | 9484 KiB |
| 01_test_11.txt | TLE | 2208 ms | 9556 KiB |
| 01_test_12.txt | TLE | 2208 ms | 9548 KiB |
| 01_test_13.txt | TLE | 2208 ms | 9464 KiB |
| 01_test_14.txt | TLE | 2208 ms | 9604 KiB |
| 01_test_15.txt | TLE | 2208 ms | 8720 KiB |
| 01_test_16.txt | TLE | 2208 ms | 9700 KiB |
| 01_test_17.txt | TLE | 2208 ms | 8480 KiB |
| 01_test_18.txt | TLE | 2208 ms | 9452 KiB |
| 01_test_19.txt | TLE | 2208 ms | 8884 KiB |
| 01_test_20.txt | TLE | 2208 ms | 9560 KiB |
| 01_test_21.txt | TLE | 2208 ms | 8740 KiB |
| 01_test_22.txt | TLE | 2208 ms | 9544 KiB |
| 01_test_23.txt | TLE | 2207 ms | 8284 KiB |
| 01_test_24.txt | TLE | 2208 ms | 9540 KiB |
| 01_test_25.txt | TLE | 2208 ms | 8232 KiB |
| 01_test_26.txt | TLE | 2208 ms | 9552 KiB |
| 01_test_27.txt | TLE | 2208 ms | 8692 KiB |
| 01_test_28.txt | TLE | 2208 ms | 9604 KiB |
| 01_test_29.txt | TLE | 2208 ms | 8444 KiB |
| 01_test_30.txt | TLE | 2208 ms | 9540 KiB |
| 01_test_31.txt | TLE | 2210 ms | 7760 KiB |
| 01_test_32.txt | TLE | 2208 ms | 9608 KiB |
| 01_test_33.txt | TLE | 2207 ms | 8312 KiB |
| 01_test_34.txt | TLE | 2208 ms | 9488 KiB |
| 01_test_35.txt | TLE | 2208 ms | 8424 KiB |
| 01_test_36.txt | TLE | 2207 ms | 9452 KiB |
| 01_test_37.txt | TLE | 2207 ms | 7348 KiB |
| 01_test_38.txt | TLE | 2210 ms | 9600 KiB |
| 01_test_39.txt | TLE | 2207 ms | 7924 KiB |
| 01_test_40.txt | TLE | 2208 ms | 9488 KiB |
| 01_test_41.txt | TLE | 2211 ms | 7876 KiB |
| 01_test_42.txt | TLE | 2207 ms | 9556 KiB |
| 01_test_43.txt | AC | 1 ms | 3488 KiB |
| 01_test_44.txt | AC | 65 ms | 6308 KiB |
| 01_test_45.txt | TLE | 2207 ms | 6448 KiB |