Submission #1165667


Source Code Expand

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333

using namespace std;
int i,j,m,n,p,k,ans,sum[N],K,s[N];
multiset<int>st;
multiset<int>::iterator it;
char c[N];
int main()
{
		scanf("%d%d",&n,&K);
		for (;n--;)
		{
				scanf("%s",c);
				sum[c[0]-'A']++;
		}
		for (i=0;i<26;++i) if (sum[i]) st.insert(sum[i]);
		while (st.size()>=K)
		{
				it=--st.end();
				for (i=1;i<=K;++i) s[i]=*it,--it;
				for (i=1;i<=K;++i) st.erase(st.find(s[i]));
				for (i=1;i<=K;++i) if (s[i]>1) st.insert(s[i]-1);
				++ans; 
		}
		printf("%d\n",ans); 
}

Submission Info

Submission Time
Task B - Problem Committee
User qiaoranliqu
Language C++14 (GCC 5.4.1)
Score 100
Code Size 901 Byte
Status AC
Exec Time 3 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:31:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&n,&K);
                      ^
./Main.cpp:34:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",c);
                  ^

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 1 ms 256 KB
01_sample.txt AC 1 ms 256 KB
corner_case_20.txt AC 1 ms 256 KB
corner_case_21.txt AC 1 ms 256 KB
corner_case_22.txt AC 1 ms 256 KB
corner_case_23.txt AC 1 ms 256 KB
corner_case_24.txt AC 3 ms 256 KB
corner_case_25.txt AC 2 ms 256 KB
corner_case_26.txt AC 2 ms 256 KB
corner_case_27.txt AC 2 ms 256 KB
corner_case_28.txt AC 3 ms 256 KB
corner_case_29.txt AC 2 ms 256 KB
random_case_00.txt AC 3 ms 256 KB
random_case_01.txt AC 3 ms 256 KB
random_case_02.txt AC 3 ms 256 KB
random_case_03.txt AC 3 ms 256 KB
random_case_04.txt AC 3 ms 256 KB
random_case_05.txt AC 3 ms 256 KB
random_case_06.txt AC 3 ms 256 KB
random_case_07.txt AC 3 ms 256 KB
random_case_08.txt AC 3 ms 256 KB
random_case_09.txt AC 3 ms 256 KB
random_case_10.txt AC 3 ms 256 KB
random_case_11.txt AC 3 ms 256 KB
random_case_12.txt AC 3 ms 256 KB
random_case_13.txt AC 3 ms 256 KB
random_case_14.txt AC 3 ms 256 KB
random_case_15.txt AC 3 ms 256 KB
random_case_16.txt AC 3 ms 256 KB
random_case_17.txt AC 3 ms 256 KB
random_case_18.txt AC 3 ms 256 KB
random_case_19.txt AC 3 ms 256 KB