提交时间:2026-04-15 19:58:23
运行 ID: 436460
#include <iostream> #include <algorithm> using namespace std; int main() { int M, N; cin >> M >> N; int def[1005], atk[1005]; for (int i = 0; i < M; i++) cin >> def[i]; for (int i = 0; i < N; i++) cin >> atk[i]; sort(def, def + M); sort(atk, atk + N); int i = 0, j = 0; while (i < M && j < N) { if (atk[j] > def[i]) { i++; j++; } else { j++; } } if (i < M) { cout << 0 << endl; } else { int sum = 0; for (int k = j; k < N; k++) { sum += atk[k]; } cout << sum << endl; } return 0; }