minh huyen thoai
@eiu12
Angola, eeqwe
Joined Mar 2017
World Rank: #119932 (0 points)
Institution: eqwe
using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Threading.Tasks; namespace EIUGRDSA { class Program { static void Main(string[] args) { int m, p, n; m = NextInt(); p = NextInt(); n = NextInt(); int[] sv = new int[m]; int[] bt = new int[p]; for (int i = 0; i < m; i++) sv[i] = NextInt(); for (int i = 0; i < p; i++) bt[i] = NextInt(); int[,] kq = new int[n, 3]; for (int i = 0; i < n; i++) { kq[i, 0] = NextInt(); kq[i, 1] = NextInt(); kq[i, 2] = NextInt(); } for (int i = 0; i < n - 1; i++) { for (int k = i + 1; k < n; k++) { if (kq[i,0] > kq[k, 0]) { for (int r = 0; r < 3; r++) { int tmp = kq[i, r]; kq[i, r] = kq[k, r]; kq[k, r] = tmp; } } } } for (int i = 0; i < sv.Length; i++) { int sum = 0; int count = 0; for (int k = 0; k < n; k++) { if (kq[k,0] == sv[i]) { count++; sum += kq[k, 2]; } } if (count != 0) Console.WriteLine(sv[i] + " " + Math.Round(sum *1.0/count)); else Console.WriteLine(sv[i] + " 0"); } } #region Input wrapper static int s_index = 0; static List<string> s_tokens; private static string Next() { while (s_tokens == null || s_index == s_tokens.Count) { s_tokens = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); s_index = 0; } return s_tokens[s_index++]; } private static bool HasNext() { while (s_tokens == null || s_index == s_tokens.Count) { s_tokens = null; s_index = 0; var nextLine = Console.ReadLine(); if (nextLine != null) { s_tokens = nextLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } else { return false; } } return s_tokens.Count > 0; } private static int NextInt() { return Int32.Parse(Next()); } private static long NextLong() { return Int64.Parse(Next()); } #endregion } }
Activity over the last year
Effectiveness
- Problems solved
- 0
- Solutions submitted
- 0