|
|
back to threadReply to message- Messages should be written in English and correspond to the matter of the website.
- Messages should not contain offences and obscene words.
- Messages should not contain correct solutions.
Почему TLE 8 ? Оптимизировал на сколько мог / Why TLE 8 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int count = 0, j, n, m, t, i; n = int.Parse(Console.ReadLine()); int[] p_dat = new int[n]; for (i = 0; i < n; i++) { p_dat[i] = int.Parse(Console.ReadLine()); } m = int.Parse(Console.ReadLine()); int[] s_dat = new int[m]; for (i = 0; i < m; i++) { s_dat[i] = int.Parse(Console.ReadLine()); } for (i = 0; i < n - 1; i++) { if (p_dat[i] == p_dat[i + 1]) { p_dat[i] = p_dat[i + 1]; i--; n--; } } p_dat = p_dat.Distinct().ToArray(); count = 0; for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { if (s_dat[i] == p_dat[j]) { count++; } } } Console.WriteLine(count); //Console.ReadKey(); } } }
|
|
|