|
|
back to boardWA 16 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _1788 { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int n = int.Parse(input[0]); int m = int.Parse(input[1]); int[] g = new int[n]; int[] b = new int[m]; input = Console.ReadLine().Split(' '); for (int i = 0; i < n; i++) { g[i] = int.Parse(input[i]); } input = Console.ReadLine().Split(' '); for (int i = 0; i < m; i++) { b[i] = int.Parse(input[i]); } int res = int.MaxValue; Array.Sort(g); Array.Sort(b); int ans = 0; if (n>=m) { for (int i = 0; i < n-m; i++) { ans += g[i]; } Console.WriteLine(ans); return; }
for (int i = 0; i <= n; i++) { ans = 0; for (int j = 0; j < m-i; j++) { ans += b[i] * i; } for (int q = 0; q < n-i; q++) { ans += g[q]; } res = Math.Min(res, ans); } Console.WriteLine(res); Console.ReadLine(); } } } Edited by author 15.05.2012 20:33 Re: WA 16 2 5 100 100 1 1 1 1 1 ans: 6 Re: WA 16 i passed this test corectly, but still have WA16 Re: WA 16 2 5 100 100 1 2 3 4 5 ans: 12
just stupid bug, if you will got AC, remove your code from forum )) Edited by author 19.05.2012 02:24 Re: WA 16 you should change >ans += b[i] * i; to >abs += b[j] * i; because when i=n you skip the cheapest elements from b[m]; Edited by author 11.07.2012 04:03 |
|
|