|
|
What's the test#4? I'm sure my solution is correct: #include <algorithm> #include <array> #include <iostream> #include <limits> uint32_t *arr_n; uint32_t *arr_m; int n, m; uint64_t max_sum = 0; uint32_t min_popularity = std::numeric_limits<uint32_t>::max(); void find_most_popular_route(int i, int j, uint64_t sum, uint32_t cur_min) { if (i == n - 1 && j == m - 1) { if (sum > max_sum) { max_sum = sum; min_popularity = cur_min; } return; } if (i < n - 1) { find_most_popular_route(i + 1, j, sum + arr_m[j], std::min(cur_min, arr_m[j])); } if (j < m - 1) { find_most_popular_route(i, j + 1, sum + arr_n[i], std::min(cur_min, arr_n[i])); } } int main() { std::cin >> n >> m; if (n > 100000 || n < 2 || m > 100000 || m < 2) return 0; arr_n = new uint32_t[n]; for (int i = 0; i < n; i++) { std::cin >> arr_n[i]; } arr_m = new uint32_t[m]; for (int i = 0; i < m; i++) { std::cin >> arr_m[i]; } std::cout << std::endl << std::endl; find_most_popular_route(0, 0, 0, min_popularity); std::cout << min_popularity << std::endl; // std::cout << max_sum << std::endl; delete[] arr_n; delete[] arr_m; return 0; } I have WA4. Can someone give me that test ? You don't must develop hard solution. Your work should not payed many time. Just pay attention, and look again on tests. Attention will save your time. I am sorry, for my poor English. Good luck! Edited by author 18.10.2015 16:52 Нужен максимум из 4-х минимумов) I got WA at test 18. Any tests for me? Got it fixed just, was using wrong indexing -> for rows used N, however, I had to use M. I use only 2 loops for 1 to 10000 but get TLE11... why? -- Edited by author 14.03.2016 22:38 Edited by author 16.03.2016 09:37 10^5 is 100000, not 10000. Fix that and get AC. Why the "coolest" rout is 4? 4 + 7 + 8 = 19, isn't it? "Определим крутость маршрута как минимальную популярность группы среди всех улиц, по которым рокеры проедут". <deleted> Edited by author 17.10.2015 14:47 |
|
|