Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1},
ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
long long gcd(long long a, long long b) {
if (!a) return b;
return gcd(b % a, a);
}
long long lcm(long long a, long lo... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int lettersNumbersShowed[1000];
int lettersInserted[1000];
int letters[1000];
int greedyChoice[1000];
int main(int argc, const char* argv[]) {
string str;
string fullAns;
cin >> str;
int n;
scanf(" %d", &n);
string ans;
int ti... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.*;
import java.util.*;
public class A {
public static void main(String[] args) throws Throwable {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
char[] s = in.readLine().toCharArray();
int[] kohl = new int[26];
for (char c : s) {
kohl[c - 'a']++;
}
... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.PrintWriter;
public class P335A {
public static void main(String[] args) {
InputReader in = new InputReader();
String s = in.next();
int n = in.nextInt();
int[] counts = new int[26];
int len = s.length();
for (int i = 0; i < len; i++) {
c... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | def get_time(num_times, stick_number):
if stick_number == 0:
return 10000000
else:
ans = num_times/stick_number
if num_times%stick_number > 0:
ans += 1
return ans
st = raw_input()
nt = {}
for c in st:
if c in nt:
nt[c] += 1
else:
nt[c] = 1
sn = {}
for c in st:
sn... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.*;
import java.math.*;
import java.math.BigInteger;
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc=new Scanner (System.in);
String str=sc.next();
int n=sc.nextInt();
int arr[]=new int [26];
Set<Integer>set =new HashSet<>();
for(int i=0;i<str.length... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | def check(mid):
ans = []
res = 0
for c, count in d:
tmp = count // mid
if (count % mid != 0):
tmp += 1
ans.append((c, tmp))
res += tmp
return res <= n, ans
a = input()
n = int(input())
d = dict()
t = 0
for i in a:
if i not in d:
d[i] = 1
... | PYTHON3 |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Template implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
void init() throws FileNotFoundException {
try {
in = new BufferedReader(new FileReader... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 |
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
new Main().run();
}
StreamTokenizer in;
PrintWriter out;
//deb//////////////////////////////////////////... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.util.*;
public class A {
static final int LETTERS = 'z' - 'a' + 1;
static final int INF = 100000;
static class Counter{
int n;
char c;
Counter(char c, int n){
this.c = c;
this.n = n;
}
}
static int [][] memo;
static List<Counter> distinct;
static int rec(int i, int left){
if (i == di... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int MAXSIZE = 100 + 10;
int main() {
string s;
int n, num[26 + 10], type = 0;
int num2[26 + 10];
fill(num, num + 26 + 10, 0);
fill(num2, num2 + 20 + 10, 0);
cin >> s;
cin >> n;
for (int i = 0; i < (int)s.length(); i++) {
if (!num[(int)s[i] - 96]) t... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int Maxn = 1100, Maxm = 101;
char str[Maxn];
int cnt[Maxm];
int n, m;
bool check(int vtimes) {
int sum = 0;
for (int i = 0; i < (26); ++i)
sum += cnt[i] / vtimes + (cnt[i] % vtimes != 0);
return sum <= m;
}
int bSearch() {
int l = 1, r = n, res = -1;
whi... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | from collections import Counter
def main():
s = raw_input().strip()
l = int(raw_input())
d = Counter(s)
if len(d)>l:
print -1
return
num_sheet = 1
len_sheet = 0
while True:
c = 0
for x in d.itervalues():
c += (x+num_sheet-1)/num_sheet
if c ... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long ch[30];
bool check(long long k, long long n) {
long long res = 0;
for (long long i = 0; i < 30; i++)
if (ch[i]) res += ch[i] / k + (ch[i] % k != 0);
if (res <= n) return true;
return false;
}
int main() {
string s;
cin >> s;
long long n;
cin >>... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.*;
import java.util.*;
public class test {
static int getLen(HashMap<Character, Integer> map, int k){
int n = 0;
for (Map.Entry<Character, Integer> elem : map.entrySet()){
n += Math.ceil(((double) elem.getValue()) / k);
}
return n;
}
public static... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n;
char a[1010];
int num[30];
int t[30];
int main() {
while (~scanf("%s", a)) {
scanf("%d", &n);
memset(num, 0, sizeof(num));
for (int i = 0; a[i]; i++) num[a[i] - 'a']++;
int cnt = 0;
for (int i = 0; i < 26; i++)
if (num[i]) cnt++;
if (c... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
public class Classical {
static double win,lose;
static int itr= 0;
public static void main(String[] ar... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
vector<long long int> g[100005];
long long int vis[100005];
long long int prime[5000003] = {0};
long long int ncr[2005][2005];
long long int fact[1000005];
long long int inv[1000005];
vector<long long int> ans;
vector<long long int> divisor(long long int n) {
vector<long ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
string s;
int m;
int n;
const int maxL = 50;
int veces[maxL];
void contarApariciones() {
for (int i = 0; i < (int)maxL; i++) veces[i] = 0;
for (int i = 0; i < (int)s.size(); i++) veces[s[i] - 'a']++;
}
int cantLetras() {
set<char> letras;... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
public class Main implements Runnable {
int INF = (int) 1e9;
List<Integer> edges[];
int anc[][];
int ts[], te[];
int t;
private void ... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const long long int MOD = 0ll;
const long long int INF = 3e18;
long long int power(long long int base, long long int exp) {
long long int res = 1;
while (exp > 0) {
if (exp % 2 == 1) res = (res * base);
base = (base * base);
exp /= 2;
}
return res;
}
lon... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, mas[30];
string s;
cin >> ws >> s >> n;
for (int i = 0; i < 30; i++) mas[i] = 0;
for (int i = 0; i < s.size(); i++) {
mas[s[i] - 'a']++;
}
int l = 0, r = 2000;
while (l < r) {
int s = (l + r) / 2;
if (s == 0) {
l = 1;
... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | s = raw_input()
n = input()
f = {}
for c in s: f[c] = f.get(c, 0) + 1
if n < len(f):
print -1
quit()
l, r = 1, len(s)
while l < r:
m = l + r >> 1
if n < sum((v + m - 1) / m for v in f.itervalues()): l = m + 1
else: r = m
print l
a, s = '', 0
for c, v in f.iteritems():
t = (v + l - 1) / l
s += t
a += c * t
pr... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int ns, n;
char s[1005];
int F[26];
bool f(int k) {
int cnt = 0;
for (int i = 0; i < (26); i++)
if (F[i]) cnt += (F[i] - 1) / k + 1;
return cnt <= n;
}
int main() {
while (scanf("%s%d", s, &n) == 2) {
memset(F, 0, sizeof(F));
ns = strlen(s);
for (int... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
string s;
int n, cnt;
int c[30];
int need[30];
bool pos(int u) {
int ret = 0;
for (int i = 0; i < 26; ++i) {
need[i] = (int)ceil((double)c[i] / u);
if (need[i]) ret += need[i];
}
return (ret <= n);
}
int main() {
cin >> s >> n;
for (int i = 0; i < s.size... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class CF335A {
public static void main(String[] args) throws NumberFormatException, IOException {
Scanner sc = new Scanner(Syste... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long dbg = 0;
template <typename A, typename B>
ostream& operator<<(ostream& cout, pair<A, B> const& p);
template <typename A>
ostream& operator<<(ostream& cout, vector<A> const& v);
template <typename A, typename B>
istream& operator>>(istream& cin, pair<A, B>& p);
te... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.InputStreamReader;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.u... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int freq[500];
string calcular(int k, int n) {
string res;
char relleno;
for (int i = 0; i < 500; i++) {
if (!freq[i]) continue;
relleno = i;
int cant = freq[i] / k;
if (freq[i] % k) cant++;
res += string(cant, i);
}
if (res.size() < n) {
r... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | a={}
for c in raw_input():
a[c]=a.get(c,0)+1
n=input()
l,h=1,10000
while l<h:
m=(l+h)/2
t=n
for c in a:
t-=(a[c]+m-1)/m
if t<0:
l=m+1
else:
h=m
if l>1010:
print -1
else:
print l
t=''
for c in a:
t+=c*((a[c]+l-1)/l)
t+='a'*(n-len(t))
print t
| PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
vector<int> cnt(26, 0);
int gen_ans(int k) {
if (k == 0) return 1001;
int len = 0;
for (int i = 0; i < 26; i++) {
if (cnt[i] != 0) len += ceil((float)cnt[i] / k);
}
return len;
}
int main() {
string s;
cin >> s;
int n;
cin >> n;
for (int i = 0; i < s... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
char s[1010];
int cnt[30] = {0}, n, len, cNum = 0;
int use[30] = {0}, t;
vector<int> v;
bool comp(const int &a, const int &b) {
int i = cnt[a] / use[a] + (cnt[a] % use[a] == 0 ? 0 : 1);
int j = cnt[b] / use[b] + (cnt[b] % use[b] == 0 ? 0 : 1);
return i < j;
}
int main... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author ffao
... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
long long max(long long a, long long b) {
if (a < b) return b;
return a;
}
long long min(long long a, long long b) {
if (a < b) return a;
return b;
}
long long ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | from collections import Counter
s = input()
n = int(input())
d = Counter()
for c in s:
d[c] += 1
if len(d) > n:
print(-1)
else:
left = 0
right = 10**10
s = ""
lastok = ("", 0)
while left + 1 < right:
mid = (left + right) // 2
s = ""
for (c, cnt) in d.items():
... | PYTHON3 |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
void solve() {
string s;
long long n, i, x, y, d;
cin >> s >> n;
set<long long> ss;
map<char, long long> mp;
for (i = 0; i < s.length(); i++) {
ss.insert(s[i]);
mp[s[i]]++;
}
if (ss.size() > n) {
cout << -1 << '\n';
} else {
for (i = 1; i <... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, zheng = 0, mmax = 0, strc, stra, cuowu;
char a[1000], b[26], c[1000];
double bb[26], sheng[26], bisheng[26], cc[26];
cin >> a;
cin >> n;
sort(a, a + strlen(a));
memset(c, 0, sizeof(c));
b[0] = 'a';
for (int i = 1; i < 26; i++) {
b[i... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
bool isOK(int k);
string s;
int n;
int a[30];
int main() {
cin >> s >> n;
int size = s.size();
int l = ceil(size / n), r = 1000;
memset(a, 0, sizeof(0));
for (int i = 0; i < size; ++i) {
a[s[i] - 'a']++;
}
int diff = 0;
for (int i = 0; i < 26; ++i) {
... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.io.Writer;
import java.math.BigInteger;
import jav... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int N = 2000001;
const int INF = 100000000;
void solve() {
string s, d;
cin >> s;
int n;
cin >> n;
vector<int> a(26, 0), b(26);
for (long long int i = 0; i < (s.size()); i++) {
a[s[i] - 'a']++;
}
long long int k = 0, sum = 0;
k = *max_element(a.b... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, k[30];
bool check(int s) {
int ret = 0;
for (int i = 0; i <= 26; i++)
if (k[i]) ret += (k[i] - 1) / s + 1;
if (ret > n) return false;
return true;
}
string s;
int main() {
cin >> s >> n;
int j;
for (int i = 0; i < s.size(); i++) k[s[i] - 'a']++;
f... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
public class Main implements Runnable {
int INF = (int) 1e9;
List<Integer> edges[];
int anc[][];
int ts[], te[];
int t;
private void ... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
public class A implements Runnable {
private void solve() throws IOException {
String s = nextToken();
int n = nextInt();
i... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.*;
import java.util.*;
public class Main {
static BufferedReader reader;
static StringTokenizer tokenizer;
static PrintWriter writer;
static int nextInt() throws IOException {
return Integer.parseInt(nextToken());
}
static long nextLong() throws IOException {
return Long.parseLong(nextToken(... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
char str[1024], ans[1024];
int cnt[32];
bool check(int n, int k) {
int i, sum = 0;
for (i = 0; i < 26; ++i) {
sum += (cnt[i] + k - 1) / k;
}
return sum <= n;
}
int solve(int n) {
int low = 1, high = strlen(str), mid, ret = -1;
while (low <= high) {
mid =... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.*;
import java.util.*;
public class Main {
private static void solve(InputReader in, OutputWriter out) {
String s = in.next();
int n = in.nextInt();
Map<Character, Integer> letters = new HashMap<>();
int maxCnt = 0;
for (int i = 0; i < s.length(); i++) {
... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(S... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import sys
import math
sys.setrecursionlimit(100000)
#sys.stdin = open("INP.txt", 'r')
# sys.stdout = open("OUT.txt", 'w')
def main():
s = input()
n = int(input())
M = dict()
for char in s:
if char in M:
M[char] += 1
else:
M[char] = 1
if n < len(M):
... | PYTHON3 |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int a[30];
int n;
bool check(int x) {
int cont = 0;
for (int i = 0; i < 30; i++) {
if (a[i] != 0) cont += (int)ceil(a[i] / (double)x);
}
if (cont <= n) return true;
return false;
}
int main() {
string s;
cin >> s;
cin >> n;
int len = s.size();
int mx... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class C {
public static void main(String[] args) throws Exception{
Scanner sc = new Scanner(System.in);
PrintWriter ou... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writabl... | PYTHON3 |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
cin >> s;
long long n;
cin >> n;
long long sz = s.size();
long long a[26] = {0};
map<char, long long> m;
for (long long i = 0; i < sz; i++) {
a[s[i] - 'a'] += 1;
m[s[i]] += 1... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.*;
import java.util.*;
public final class Template {
private static Scanner sc = new Scanner(System.in);
private static int frequency[] = new int[26];
public static void main(String[] args) {
String word = sc.next();
int sheetLength = sc.nextInt();
int uniqueChars = 0;
for (int i = 0; i < ... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
char s[1111];
int cnt[33];
struct cs {
int cnt, alp;
};
cs css[33];
int pc;
int cmp(cs c1, cs c2) { return c1.cnt > c2.cnt; }
int ks[33];
int main() {
int n;
scanf("%s%d", s, &n);
int len = strlen(s);
for (int i = 0; i != len; i++) {
cnt[s[i] - 'a']++;
}
for (int i = 0; i != 2... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
string s;
int n;
int H[30];
int ans;
vector<pair<int, int> > V;
string fin;
bool poss(int cnt) {
int sz = V.size();
int k = 0;
string tmp;
for (int i = 0; i < sz; i++) {
int lol = V[i].first / cnt;
if (V[i].first % cnt != 0) lol++;
for (int j = 0; j < lo... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
char ch, s[1000];
int len, tot, l, r, i, j, mid, b[50], tl;
int main() {
scanf("%c", &ch);
while (ch != '\n') {
if (!b[ch - 'a' + 1]) tot++;
b[ch - 'a' + 1]++;
scanf("%c", &ch);
}
scanf("%d", &len);
if (len < tot) {
puts("-1");
return 0;
}
... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.util.*;
import java.io.*;
public class Main
{
public static void main(String []args) throws IOException {
FastScanner in = new FastScanner(System.in);
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
solve(in, out);
in.close();
o... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int const N = 1010, Z = 33;
int n, r[Z], t[Z];
string s;
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> s >> n;
for (int i = 0; i < s.size(); i++) r[s[i] - 'a']++;
for (int k = 1; k < N; k++) {
int res = 0;
for (int i = 0; i < 26; ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, fr[60];
char s[1010];
while (scanf(" %s %d", s, &n) == 2) {
memset(fr, 0, sizeof(fr));
for (int i = 0; s[i]; i++) fr[s[i] - 'a']++;
int res = -1;
for (int qs = 1; qs <= 1000; qs++) {
int us = 0;
for (int i = 0; i < 26; i... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
string s;
long long cnt[200];
int main() {
cin >> s;
long long n = s.size();
for (int i = 0; i < 200; i++) cnt[i] = 0;
for (int i = 0; i < n; i++) ++cnt[s[i]];
long long len;
cin >> len;
long long ll = 1, rr = n + 1;
while (ll < rr) {
long long mid = (ll... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
struct _ {
ios_base::Init i;
_() {
cin.sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(10);
}
} ___;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << endl;
}
t... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
char s[424242];
int cnt[424];
int main() {
scanf("%s", s);
int n = strlen(s);
for (int i = 32; i < 256; i++) cnt[i] = 0;
for (int i = 0; i < n; i++) cnt[s[i]]++;
int len;
scanf("%d", &len);
int ll = 1, rr = n + 1;
while (ll < rr) {
int mid = (ll + rr) >>... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.util.Arrays.*;
public class A {
private static final int mod = (int)1e9+7;
IOFast io = new IOFast();
public void run() throws IOException {
final char[] cs = io.next();
final int n = io.nextInt();
... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
inline int intceil(int a, int b) {
if (a % b) return a / b + 1;
return a / b;
}
int main() {
string s;
int n, min_l = 0;
cin >> s >> n;
vector<int> frecv(26, 0), sol(26, 0);
for (auto &&ch : s) {
if (frecv[ch - 'a'] == 0) {
min_l++;
sol[ch - 'a... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 |
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author pttrung
*/
public class A {
public static void main(String[] args) {
Scanner in = new Scanner(new Inp... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 |
import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args) {
new Main().run();
}
class InputScanner {
BufferedReader br;
StringTokenizer st;
boolean eof;
public InputScanner(String fileName) throws FileNotFoundException {
... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | s = raw_input()
N = len(s)
n = int(raw_input())
letters = [0]*26
difLet = ""
for character in s:
index = ord(character)-ord('a')
letters[index] += 1
sets = set(s)
diff = len(sets)
for j in sets:
difLet += j
if n < diff:
print "-1"
elif n == diff:
print max(letters)
print difLet
else:
if n > N:
print 1
print ... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 |
public class A {
private final static boolean autoflush = false;
public A () {
char [] C = sc.nextChars();
int N = sc.nextInt();
int [] L = new int [200];
int [] M = new int [200];
for (char c : C) {
++L[c];
if (M[c] == 0) {
M[c] = 1;
--N;
}
}
if (N < 0)
exit(-1);
int res = 0... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | //package codeforces.train;
import java.io.*;
public class ProblemA {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
int[] readInts() throws IOException {
String[] strings = reader.readLine().s... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int MAX = 30;
int num[MAX], x[MAX];
char s[1000 + 10];
int main() {
int n;
while (cin >> s >> n) {
int m = n;
string a;
memset(num, 0, sizeof num);
int len = strlen(s), sum = 0;
for (int i = 0; i < len; ++i) {
if (!num[s[i] - 'a']) ++sum;... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | // Don't place your source in a package
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
// Please name your class Main
public class Main {
//static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
/*static int read() throw... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int a[26], b[26];
int main() {
string s;
cin >> s;
for (int i = 0; i < s.size(); i++) a[s[i] - 'a']++;
int n;
cin >> n;
int counter = 0;
string result = "";
for (int i = 0; i < 26; i++) {
if (a[i] != 0) {
counter++;
b[i] = 1;
result += ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1005;
int cnt[maxn], n;
char str[maxn];
int main() {
scanf("%s%d", str, &n);
int m = strlen(str);
for (int i = 0; i < m; i++) cnt[str[i] - 'a']++;
int num = 0;
for (int i = 0; i < 26; i++)
if (cnt[i]) num++;
if (n... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import math
s = raw_input().strip()
n = int(raw_input().strip())
sl = list(s)
sl.sort()
letters = [0 for i in range(26)]
for i in sl:
letters[ord(i)-97] += 1
turns = [(99999 if letters[i] > 0 else -1) for i in range(26)]
countinans = [0 for i in range(26)]
used = 0
while used < n:
x = turns.index(max(tu... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
inline int in() {
int32_t x;
scanf("%d", &x);
return x;
}
inline string get() {
char ch[1000010];
scanf("%s", ch);
return ch;
}
const int MAX_LG = 21;
const long long maxn = 1e6 + 10;
const long long base = 29;
const long long mod = 1e9 + 7;
const long long INF ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import math
from sys import stdin
from math import ceil
if __name__ == '__main__':
s = input()
n = int(input())
dictionary = {}
for i in s:
if i in dictionary:
dictionary[i] = dictionary[i] + 1
else:
dictionary[i] = 1
if len(dictionary) > n:
print(-... | PYTHON3 |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int i, j, k, KK, R, NN;
string in;
map<char, int> MP;
int mn;
int main() {
cin >> in;
cin >> NN;
mn = 0;
for (int i = 0; i < in.size(); i++) {
if (MP[in[i]] <= 0) mn += 1;
MP[in[i]] += 1;
}
if (mn > NN) {
cout << -1 << endl;
return 0;
}
int l... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, ans, c[26];
char s[1000];
bool Check(int x) {
int ans = 0;
for (int i = 0; i <= 25; i++) ans += (c[i] + x - 1) / x;
return ans <= n;
}
void Print(int x) {
string res = "";
for (int i = 0; i <= 25; i++) {
int l = (c[i] + x - 1) / x;
char ch = 'a' + i... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | ch = raw_input()
N = (int)( raw_input() )
cnt = []
need = []
for _ in range(26) :
cnt.append( 0 )
need.append( 0 )
for c in range( len(ch) ) :
cnt[ ord(ch[c])- ord('a') ] += 1
def is_ok( a ):
all = 0
for c in range( 26 ):
need[c] = ( cnt[c] + a - 1 ) / ... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | from collections import defaultdict
s = input()
n = int(input())
if len(set(s)) > n:
print(-1)
else:
hist = defaultdict(int)
for c in s:
hist[c] += 1
for ans in range(1, 2000):
cur_need = 0
for c in hist:
# ans * t >= hist[c]
# t >= hist[c]... | PYTHON3 |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class A {
public static void main(String[] args) throws IOException {
PrintWriter out = new PrintWriter(System.out);
BufferedReader br = ... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class A {
public static void main(String[] args) throws IOException {
PrintWriter out = new PrintWriter(System.out);
BufferedReader br = ... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n;
string s;
string ans = "";
map<char, long long> m;
bool check(long long x) {
ans = "";
set<pair<long long, char> > st;
for (auto it : m) {
ans += it.first;
if (it.second - x > 0) st.insert({it.second - x, it.first});
... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long countBits(long long n) {
long long cnt = 0;
while (n) {
cnt++;
n >>= 1;
}
return cnt;
}
long long power(long long a, long long n, long long d) {
long long res = 1;
while (n) {
if (n & 1 != 0) {
res = ((res % d) * ((a % d + d) % d)) % ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int cnt[35], n;
char ch[1010];
bool check(int k) {
int ans = 0;
for (int i = 0; i < 26; i++) {
int t = cnt[i];
if (t) {
ans += t / k;
t %= k;
if (t) ans++;
}
}
if (ans <= n) return true;
return false;
}
int len;
int wotamajingranshuig... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
char s[1003];
char res[1003];
int n;
int coun[33];
int coun3[33];
int main() {
scanf("%s", s);
scanf("%d", &n);
int i, j;
for (i = 0; s[i]; i++) coun[s[i] - 'a']++;
int coun2 = 0;
for (i = 0; i < 30; i++)
if (coun[i] > 0) coun2++;
if (coun2 > n) {
prin... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
map<char, int> mp, curmp;
vector<pair<int, char> > v, resvec;
int main() {
int n;
string s;
cin >> s >> n;
for (auto x : s) mp[x]++;
if (n < mp.size()) return cout << -1, 0;
string ress;
int res = -1;
if (n >= s.size()) {
ress = s;... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long has[26];
long long check(long long k) {
long long ans(0);
for (long long i = 0; i < 26; i++) {
ans += ceil(double(has[i]) / k);
}
return ans;
}
int main() {
string s;
long long n, ans(-1);
cin >> s >> n;
if (n >= s.length()) {
cout << 1 << ... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.util.*;
public class CF335A {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
char []input = sc.nextLine().toCharArray();
int n = Integer.parseInt(sc.nextLine());
int []inputCharFreq = new int[26];
int uniqueChars = 0;
f... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
const int INF = 1 << 29;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int& n, int b) { n |= two(b); }
inline void unset_bit(int& n, int b... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | def main():
from sys import stdin
s = stdin.readline()[:-1]
n = int(stdin.readline())
d = {}
for c in s:
if c in d:
d[c] += 1
else:
d[c] = 1
l = 1
r = max(map(lambda x:x[1],list(d.iteritems()))) + 1
from math import ceil
def check(t):
... | PYTHON |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReade... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long a[28], b[28], n;
bool check(long long val) {
long long x = 0, y, i;
for (i = 0; i < 26; i++) {
if (a[i] > 0) {
y = (a[i] % val == 0) ? a[i] / val : a[i] / val + 1;
x += y;
}
}
if (x > n)
return false;
else
return true;
}
int m... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int cnt[1000];
char str[1111];
int len;
int isok(int m, int n) {
int l = n, te;
for (int i = 'a'; i <= 'z'; i++) {
if (cnt[i] % m == 0)
te = cnt[i] / m;
else
te = cnt[i] / m + 1;
l -= te;
if (l < 0) return 0;
}
return 1;
}
void put(int m,... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
map<char, int> m;
string s;
int n;
string ans;
bool ok(int a) {
ans.clear();
string k;
for (auto p : m) {
k += string((p.second + a - 1) / a, p.first);
}
if (k.size() > n) return false;
int b = k.size();
for (int i = 0; i < n - b; i++) k += s[0];
ans = k... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 1010, ALPH = 30;
string S;
int N;
map<char, int> freq;
priority_queue<pair<int, char> > pq;
int times[ALPH];
int main() {
cin >> S >> N;
for (int i = 0; i < S.size(); i++) freq[S[i]]++;
if (freq.size() > N) {
cout << -1... | CPP |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.*;
import java.util.*;
public class ProblemA {
public static final String FILE_IN = "std.in";
public static final String FILE_OUT = "std.out";
private static boolean debugMode = true;
public static void main(String[] args) throws IOException {
final Scanner reader = new Scanner(n... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out ... | JAVA |
335_A. Banana | Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly n stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length n. Piegirl wants to create a string s using stickers. She may buy as many sheets ... | 2 | 7 | import java.io.*;
import java.util.*;
public class Solution {
BufferedReader in;
StringTokenizer str;
PrintWriter out;
String SK;
String next() throws IOException {
while ((str == null) || (!str.hasMoreTokens())) {
SK = in.readLine();
if (SK == null)
return null;
str = new ... | JAVA |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.