Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace SandBox
- {
- struct Candidate
- {
- public string identifier;
- public int countTask;
- public int fine;
- }
- public class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, List<Candidate>> dictionaryVacancyCandidatesList = new Dictionary<string, List<Candidate>>();
- Dictionary<string, int> maxCountCandidatesVacancy = new Dictionary<string, int>();
- int countVacancy = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < countVacancy; i++)
- {
- string vacancyAndMaxCountCandidates = Console.ReadLine();
- string vacancy = vacancyAndMaxCountCandidates.Split(',')[0];
- int maxCountCandidates = Convert.ToInt32(vacancyAndMaxCountCandidates.Split(',')[1]);
- maxCountCandidatesVacancy.Add(vacancy, maxCountCandidates);
- dictionaryVacancyCandidatesList.Add(vacancy, new List<Candidate>());
- }
- int countCandidates = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < countCandidates; i++)
- {
- string candidate = Console.ReadLine();
- string vacancy = candidate.Split(',')[1];
- dictionaryVacancyCandidatesList[vacancy].Add(new Candidate()
- {
- identifier = candidate.Split(',')[0],
- countTask = Convert.ToInt32(candidate.Split(',')[2]),
- fine = Convert.ToInt32(candidate.Split(',')[3])
- });
- }
- List<string> candidatesList = new List<string>();
- foreach (var keyValue in dictionaryVacancyCandidatesList)
- {
- var sortedCandidate = from c in keyValue.Value
- orderby c.countTask descending, c.fine select c;
- List<Candidate> candidates = new List<Candidate>();
- candidates.AddRange(sortedCandidate.Take(maxCountCandidatesVacancy[keyValue.Key]));
- foreach (var c in candidates)
- {
- candidatesList.Add(c.identifier);
- }
- }
- candidatesList.Sort();
- foreach (var c in candidatesList)
- {
- Console.WriteLine(c);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment