Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Globalization;
- using System.Collections.Generic;
- namespace SoftUni_Exam
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- int count = 1;
- Dictionary<string, int> namesAndScores = new Dictionary<string, int>();
- Dictionary<string, int> languageAndCount = new Dictionary<string, int>();
- int score1 = 0;
- while (input != "exam finished")
- {
- List<string> lines = input.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries).ToList();
- string name = lines[0];
- string language = lines[1];
- if (lines[1] != "banned")
- {
- int score = int.Parse(lines[2]);
- if (!namesAndScores.ContainsKey(name))
- {
- namesAndScores[name] = score;
- score1 = score;
- // misho 90
- if (!languageAndCount.ContainsKey(language))
- {
- languageAndCount[language] = count;
- }
- else
- {
- languageAndCount[language]++;
- }
- }
- else
- {
- if (score >= score1 && score != 0)
- {
- namesAndScores[name] = score;
- languageAndCount[language] += count;
- }
- else
- {
- namesAndScores[name] = score1;
- languageAndCount[language] += count;
- }
- }
- }
- else
- {
- name = lines[0];
- namesAndScores.Remove(name);
- }
- input = Console.ReadLine();
- }
- Console.WriteLine("Results:");
- foreach (var kvp in namesAndScores.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{kvp.Key} | {kvp.Value}");
- }
- Console.WriteLine("Submissions:");
- foreach (var kvp in languageAndCount.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
- {
- Console.WriteLine($"{kvp.Key} - {kvp.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement