Submission #1647915


Source Code Expand

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int N, K;
    string[] P;
    void Solve() {
        //input
        N = io.Int;
        K = io.Int;
        P = new string[N];
        for (int i = 0; i < N; ++i)
            P[i] = io.String;
        //cal
        var ans = 0;
        var map = new int['z' - 'a' + 1];
        for (int i = 0; i < P.Length; ++i)
            map[P[i][0] - 'A']++;
        for (;;) {
            var cnt = 0;
            Array.Sort(map);
            Array.Reverse(map);
            for (int i = 0; i < map.Length; ++i) {
                if (map[i] > 0) { cnt++; map[i]--; }
                if (cnt == K) { ans++; break; }
            }
            if (cnt != K) break;
        }
        //ret
        Console.WriteLine(ans);
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}

class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}

Submission Info

Submission Time
Task B - Problem Committee
User rui0422
Language C# (Mono 4.6.2.0)
Score 100
Code Size 2101 Byte
Status AC
Exec Time 34 ms
Memory 13268 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 32
Set Name Test Cases
All 00_sample.txt, 01_sample.txt, corner_case_20.txt, corner_case_21.txt, corner_case_22.txt, corner_case_23.txt, corner_case_24.txt, corner_case_25.txt, corner_case_26.txt, corner_case_27.txt, corner_case_28.txt, corner_case_29.txt, random_case_00.txt, random_case_01.txt, random_case_02.txt, random_case_03.txt, random_case_04.txt, random_case_05.txt, random_case_06.txt, random_case_07.txt, random_case_08.txt, random_case_09.txt, random_case_10.txt, random_case_11.txt, random_case_12.txt, random_case_13.txt, random_case_14.txt, random_case_15.txt, random_case_16.txt, random_case_17.txt, random_case_18.txt, random_case_19.txt
Case Name Status Exec Time Memory
00_sample.txt AC 23 ms 13140 KB
01_sample.txt AC 21 ms 9172 KB
corner_case_20.txt AC 22 ms 11220 KB
corner_case_21.txt AC 22 ms 11220 KB
corner_case_22.txt AC 22 ms 11220 KB
corner_case_23.txt AC 22 ms 13268 KB
corner_case_24.txt AC 33 ms 11132 KB
corner_case_25.txt AC 24 ms 9084 KB
corner_case_26.txt AC 24 ms 9084 KB
corner_case_27.txt AC 25 ms 11132 KB
corner_case_28.txt AC 29 ms 11132 KB
corner_case_29.txt AC 25 ms 11132 KB
random_case_00.txt AC 25 ms 11132 KB
random_case_01.txt AC 25 ms 9084 KB
random_case_02.txt AC 34 ms 13180 KB
random_case_03.txt AC 25 ms 9084 KB
random_case_04.txt AC 27 ms 11132 KB
random_case_05.txt AC 26 ms 9084 KB
random_case_06.txt AC 26 ms 9084 KB
random_case_07.txt AC 26 ms 11132 KB
random_case_08.txt AC 25 ms 11132 KB
random_case_09.txt AC 26 ms 11132 KB
random_case_10.txt AC 25 ms 11132 KB
random_case_11.txt AC 26 ms 11132 KB
random_case_12.txt AC 26 ms 9084 KB
random_case_13.txt AC 25 ms 9084 KB
random_case_14.txt AC 25 ms 11132 KB
random_case_15.txt AC 25 ms 11132 KB
random_case_16.txt AC 25 ms 11132 KB
random_case_17.txt AC 25 ms 11132 KB
random_case_18.txt AC 25 ms 11132 KB
random_case_19.txt AC 25 ms 9084 KB