private ProblemOutput GenerateOutput(ProblemInput originalInput, List <Library> bestOrderedLibraries) { ProblemOutput output = new ProblemOutput(); output.libaries = new List <Library>(); int day = 0; foreach (var library in bestOrderedLibraries) { if (originalInput.NumberOfDays < day + library.LibrarySignupTime) { break; } var(libraryScore, takenBooks) = SolverHelper.GetLibraryScore(library, originalInput, day, 1); library.SendBooksToScan(takenBooks); library.LibaryStartSignUpTime = day; day += library.LibrarySignupTime; output.libaries.Add(library); } return(output); }
protected override ProblemOutput Solve(ProblemInput input) { HashSet <Library> notSelectedLibraries = new HashSet <Library>(input.Libraries); int currentTime = 0; var output = new ProblemOutput() { libaries = new List <Library>() }; int count = 0; while (currentTime < input.NumberOfDays) { List <BestLibrariesData> bestLibrariesDatas = SolverHelper.GetBestLibray(input, notSelectedLibraries, currentTime, RunParam); if (bestLibrariesDatas == null || !bestLibrariesDatas.Any()) { break; } foreach (var selectedLibrary in bestLibrariesDatas) { selectedLibrary.Library.SendBooksToScan(selectedLibrary.Books); selectedLibrary.Library.LibaryStartSignUpTime = currentTime; notSelectedLibraries.Remove(selectedLibrary.Library); currentTime += selectedLibrary.Library.LibrarySignupTime; output.libaries.Add(selectedLibrary.Library); } if (++count % 100 == 0) { Console.WriteLine(count); } } if (input.NumberOfDays == 200) { var newOutput = ReorderLibraries(output); return(newOutput); } return(output); }