Submission #1244338
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()
#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second
#define x1 gray_cat_x1
#define y1 gray_cat_y1
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
#define file "cycle"
const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
int cnt[200];
pii pp[200];
char s[200];
void solve(){
int n, k;
scanf("%d%d", &n, &k);
REP(i, 0, n){
scanf("%s", &s[0]);
cnt[s[0]]++;
}
int ans = 0;
REPN(i, 'A', 'Z'){
pp[i - 'A'] = mp(cnt[i], i);
}
while(1){
sort(pp, pp + 26);
reverse(pp, pp + 26);
if (pp[k - 1]._1 == 0){
break;
}
REP(i, 0, k){
pp[i]._1--;
}
ans++;
}
printf("%d\n", ans);
}
int main(){
//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
Submission Info
Submission Time |
|
Task |
B - Problem Committee |
User |
Timur_Sitdikov |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
1422 Byte |
Status |
AC |
Exec Time |
4 ms |
Memory |
256 KB |
Compile Error
./Main.cpp: In function ‘void solve()’:
./Main.cpp:44:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &k);
^
./Main.cpp:46:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s", &s[0]);
^
Judge Result
Set Name |
All |
Score / Max Score |
100 / 100 |
Status |
|
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 |
4 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 |
2 ms |
256 KB |
random_case_01.txt |
AC |
2 ms |
256 KB |
random_case_02.txt |
AC |
4 ms |
256 KB |
random_case_03.txt |
AC |
2 ms |
256 KB |
random_case_04.txt |
AC |
3 ms |
256 KB |
random_case_05.txt |
AC |
2 ms |
256 KB |
random_case_06.txt |
AC |
2 ms |
256 KB |
random_case_07.txt |
AC |
2 ms |
256 KB |
random_case_08.txt |
AC |
2 ms |
256 KB |
random_case_09.txt |
AC |
2 ms |
256 KB |
random_case_10.txt |
AC |
2 ms |
256 KB |
random_case_11.txt |
AC |
2 ms |
256 KB |
random_case_12.txt |
AC |
3 ms |
256 KB |
random_case_13.txt |
AC |
2 ms |
256 KB |
random_case_14.txt |
AC |
2 ms |
256 KB |
random_case_15.txt |
AC |
2 ms |
256 KB |
random_case_16.txt |
AC |
2 ms |
256 KB |
random_case_17.txt |
AC |
2 ms |
256 KB |
random_case_18.txt |
AC |
2 ms |
256 KB |
random_case_19.txt |
AC |
2 ms |
256 KB |