/* ID: vvatash1 PROG: numtri LANG: C++ */ using namespace std; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include float roundf(float x) { return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f); } int compare_ints(const void* a, const void* b) { int arg1 = *(const int*)a; int arg2 = *(const int*)b; if (arg1 > arg2) return -1; if (arg1 < arg2) return 1; return 0; } int main() { ifstream fin ("toys.in"); ofstream fout ("toys.out"); int numberChoosen = 0, numberInStore = 0; int toysPrice[6000]={0}; int toysChoosen[6000]={0}; fin >> numberChoosen >> numberInStore; for (int i = 0; i < numberChoosen; i++) fin >> toysChoosen[i]; for (int i = 0; i < numberInStore; i++) fin >> toysPrice[i]; qsort(toysChoosen, numberChoosen, sizeof(int), compare_ints); qsort(toysPrice, numberInStore, sizeof(int), compare_ints); int result = 0; for (int i = 0; i < numberChoosen; i++) { result += toysChoosen[i] * toysPrice[i]; cout << toysChoosen[i] * toysPrice[i] << " " <