Advertisement
T-D-K

Untitled

Nov 7th, 2018
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4.  
  5. namespace SockMerchant {
  6.     class Program {
  7. #if LOCAL_JUDGE
  8.         private static readonly StreamWriter writer = new StreamWriter(@"..\..\output");
  9.         private static readonly StreamReader reader = new StreamReader(@"..\..\input");
  10. #else
  11.         private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
  12.         private static readonly StreamWriter writer = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);
  13. #endif
  14.  
  15.         static void Main(string[] args) {
  16.             int n = Next();
  17.             int[] a = new int[101];
  18.             for(int i = 0; i < n; i++) {
  19.                 a[Next()]++;
  20.             }
  21.             int result = 0;
  22.             for(int i = 0; i < 101; i++) {
  23.                 result += a[i] / 2;
  24.             }
  25.             writer.WriteLine(result);
  26.  
  27.             writer.Flush();
  28.             writer.Close();
  29.         }
  30.         private static int Next() {
  31.             int c;
  32.             int res = 0;
  33.             do {
  34.                 c = reader.Read();
  35.                 if(c == -1)
  36.                     return res;
  37.             } while(c != '-' && (c < '0' || c > '9'));
  38.             int sign = 1;
  39.             if(c == '-') {
  40.                 sign = -1;
  41.                 c = reader.Read();
  42.             }
  43.             res = c - '0';
  44.             while(true) {
  45.                 c = reader.Read();
  46.                 if(c < '0' || c > '9')
  47.                     return res * sign;
  48.                 res *= 10;
  49.                 res += c - '0';
  50.             }
  51.         }
  52.  
  53.         private static int[] ReadArray(int length) {
  54.             int[] result = new int[length];
  55.             for(int i = 0; i < length; i++) {
  56.                 result[i] = Next();
  57.             }
  58.             return result;
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement