예제 #1
0
파일: Solver.cs 프로젝트: rotemtzaban/ghc17
        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);
        }
예제 #2
0
파일: Solver.cs 프로젝트: rotemtzaban/ghc17
        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);
        }