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; int cnt[28]; int main() { string s; int n, tot, len; cin >> s >> n; len = s.size(); for (int i = 0; i < len; ++i) ++cnt[s[i] - 'a']; int l = 1, r = len + 1; while (l < r) { int mid = (l + r) >> 1; int need = 0; for (int i = 0; i < 28; ++i) need += ...
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 math import ceil s = input () n = int (input ()) count = {} for i in s: if i in count: count[i] += 1 else: count[i] = 1 if len(count) > n: print (-1) else: if len(s) < n: print (1) ret = s else: l,h = len (s)//n, len (s) while (l < h): m = (l+h) // 2 tot = 0 for...
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; template <class T> inline bool gmin(T &a, T b) { if (a > b) return a = b, true; return false; } template <class T> inline bool gmax(T &a, T b) { if (a < b) return a = b, true; return false; } template <class T> T exgcd(T a, T b, T &first, T &second) { if (!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
#include <bits/stdc++.h> using namespace std; int q[26]; int n; bool Check(int x) { int req = 0; for (int i = 0; i < 26; ++i) { req += (q[i] + x - 1) / x; } return req <= n; } int main() { string s; cin >> s >> n; int dif = 0; for (int i = 0; i < s.size(); ++i) { int let = s[i] - 'a'; if (!q...
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.text.DecimalFormat; import java.util.*; import java.awt.Point; public class Newbie { static InputReader sc = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) throws IOException { solver s = ne...
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> struct T { char c; double need, curr; T(char x, double y, double z) : c(x), need(y), curr(z){}; bool operator<(const T &o) const { return need / curr < o.need / o.curr; } }; using namespace std; int N; map<char, double> M, M2; priority_queue<T> Q; string ret, S; int main() { cin >> 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
s = input() n = int(input()) cnt = {} for c in s: if cnt.get(c) == None: cnt[c] = 1 else: cnt[c] += 1 if (n < len(cnt)): print(-1) else: ansNum = 0; while(True): ansNum+=1 l = 0; char = [] for c, v in cnt.items(): need = (v + ansNum -1)//a...
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.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Banana implements Closeable { private InputReader in = new InputReader(System.in); priv...
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 main() { map<char, int> mp; int n, M = 0; string s; cin >> s >> n; int a[200]; for (char i : s) mp[i]++; for (int k = 1; k <= 1000; k++) { string ans; map<char, int> aux(mp); for (char i : s) { if (aux[i] > 0) { ans += 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 j, nrmin, s1, mij, u, p, nr1, k, max, x, nr, n, i, z, y, a[1100]; char cc, s[1100], b[1100]; int main() { gets(s); scanf("%d", &n); x = strlen(s); for (i = 0; i < x; i++) a[s[i]]++; p = 1; u = 10000; y = -1; while (p <= u) { mij = (p + u) / 2; nr...
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
k = raw_input() li = [0 for x in xrange(26)] l = raw_input() l = int(l) for x in k: li[ord(x) - ord('a')] = li[ord(x) -ord('a')] + 1 temp = sum([1 for x in li if x > 0]) if temp > l: print -1 else: lo = 0 hi = 10000 pre = hi while lo <= hi: mid = (lo + hi) / 2 c = 0; ...
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; FILE *in; FILE *out; const int MAX = 1024; int n, m; char a[MAX]; int main(void) { in = stdin; out = stdout; fscanf(in, "%s %d", a, &m); n = (int)strlen(a); map<char, int> q; for (int i = 0; i < n; i++) { if (q.find(a[i]) == q.end()) q[a[i]] = 0; q[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
#include <bits/stdc++.h> using namespace std; char buff[1003]; int cnt[26]; bool check(int ns, int n) { int s = 0; for (int i = (0); i < ((26)); i++) s += (cnt[i] + ns - 1) / ns; return s <= n; } int main() { gets(buff); int n; scanf("%d", &n); for (int i = 0; buff[i]; i++) cnt[buff[i] - 'a']++; int num...
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; inline long long minOf(long long x, long long y) { return (x < y ? x : y); } inline long long maxOf(long long x, long long y) { return (x > y ? x : y); } char arr[50000000], *ptr; long long ret; string str; inline long long get_int() { bool isNeg = false; ret = 0; 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
#include <bits/stdc++.h> using namespace std; map<char, int> m; char letters[30]; int numbers[30]; int mystring[30]; int ceiling(int top, int bottom) { return (top + bottom - 1) / bottom; } int main() { string s; int n; cin >> s >> n; for (int i = 0; i < (int)s.length(); i++) m[s[i]]++; int numChar = 0; for...
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 = (int)1e5; const int inf = (int)1e9; const double eps = 1e-8; const double pi = 3.141592653589793238462643; int main() { string s; int n; cin >> s; cin >> n; int m = ((int)(s).size()); int b[50]; for (int i = (0); i < (28); ++i) b[i] = 0; 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; int freq[130]; string calcular(int k, int n) { if (k == 0) return ""; string res; for (char i = 'a'; i <= 'z'; i++) { if (freq[i]) { int cant = freq[i] / k + (freq[i] % k != 0); res += string(cant, i); } } if (res.size() < n) res += string(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
#include <bits/stdc++.h> using namespace std; const int N = 1e7 + 5; const int inf = 1e9; const long long OO = 1e18; const long long MOD = 1e9 + 7; int main() { int n, k = 0; string s, ans = ""; cin >> s >> n; map<char, int> mp; for (auto c : s) mp[c]++; if ((int)mp.size() > n) return cout << -1, 0; for (...
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.PriorityQueue; import java.util.StringTokenizer; public class Banana { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); char[]...
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; void min_stickers(string s, int k) { int n = s.length(); vector<int> count(26, 0); vector<int> a(26, 0); for (int i = 0; i < n; i++) { count[s[i] - 'a']++; a[s[i] - 'a'] = 1; } int temp = 0; for (int i = 0; i < 26; i++) if (a[i]) temp++; if (temp...
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 sys from collections import defaultdict from Queue import PriorityQueue class Relation: def __init__(self, r, c, l): self.r = r self.c = c self.l = l def demand(self): return (self.r + self.c - 1) / self.c def __lt__(self, other): return self.demand() > other.demand() s = raw_input() ...
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; struct node { int need, temp; char ch; bool operator<(const node& a) const { return ceil((double)need / temp) < ceil((double)a.need / a.temp); } } p[101]; void init() { for (int i = 0; i <= 100; i++) p[i].need = 0, p[i].temp = 1; } priority_queue<node> q; vect...
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() S=list(set(s)) if len(S) > n: print -1;exit() from collections import defaultdict as D C=D(int) for c in s: C[c]+=1 i=1 while 1: s = 0 r = [] for k,v in C.items(): c = -(-v/i) r += k*c s += c if s <= n: break i+=1 print i print ''.join(r)+'a'*(n-le...
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; const int mod = 1e9 + 7; const int N = 5e5 + 10; string s; int dp[1001][26], f[26]; vector<pair<int, int>> v; int giveres(int pos, int indx) { if (indx == v.size()) { return 0; } if (pos == 0) return 1e9; int &ret = dp[pos][indx]; if (ret != -1) return ret; ...
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() { string s; cin >> s; int i, l, j, n, f[26] = {0}, cur[26] = {0}, cnt = 0; scanf("%d", &n); ; for (i = 0; i < s.size(); i++) f[s[i] - 'a']++; string ans = ""; for (i = 0; i < 26; i++) if (f[i]) { cnt++; cur[i] = 1; ans += '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.BufferedReader; import java.io.BufferedWriter; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class cf335a { public static void main(String[] args) { ...
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; struct cmp { bool operator()(pair<int, int> a, pair<int, int> b) { return a.first < b.first; } }; int cnt[30]; int ans[30]; int main() { string str; int n; cin >> str >> n; memset(cnt, 0, sizeof(cnt)); memset(ans, 0, sizeof(ans)); for (int i = 0; i < str...
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() { string s; cin >> s; int n; cin >> n; float arr[26] = {0}; set<char> s1; for (int i = 0; i < s.length(); i++) { s1.insert(s[i]); int x = s[i] - 97; arr[x]++; } if (s1.size() > n) { cout << "-1"; } else { string 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
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 5; int n, kind, cnt[30]; char str[maxn]; int need[30], tot; bool check(int mid) { memset(need, 0, sizeof need); tot = 0; for (int i = 0; i < 26; ++i) { need[i] = ceil(double(cnt[i]) / double(mid)); tot += need[i]; if (tot > n) return...
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 kata[1005]; int panjang, total[30], batas; int main() { scanf("%s", kata); panjang = strlen(kata); for (int i = 0; i < panjang; ++i) ++total[kata[i] - 'a']; scanf("%d", &batas); int cek = 0; for (int i = 0; i < 26; ++i) if (total[i]) ++cek; if (cek > ...
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 freq[29]; vector<char> v; int f(int x) { if (x == 0) return 0; int total = n; for (int i = 0; i < 26; i++) { double cur = ((freq[i] * 1.0) / x); int curx = ceil(cur); total -= curx; } if (total >= 0) return 1; return 0; } void do...
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 = INT_MAX; const long long INFL = LLONG_MAX; const long double pi = acos(-1); int cnt[100]; int N; string s; int main() { ios_base::sync_with_stdio(0); cout.precision(15); cout << fixed; cout.tie(0); cin.tie(0); cin >> s >> N; for (int(i) = 0, j1...
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[1005], re[1005]; int c1[27], c2[27], n, tt[27]; int jd(int x) { int i, tot = n, t1; memset(c2, 0, sizeof(c2)); for (i = 0; i < 27; i++) if (c1[i]) { t1 = (c1[i] + x - 1) / x; if (tot < t1) return 0; tot -= t1; c2[i] = t1; } c2[...
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[100005]; int i, j, p[26], ans, A, k; int main() { scanf("%s", s); for (i = 0; i < strlen(s); i++) p[s[i] - 'a']++; scanf("%d", &A); int t = 0; for (i = 1; i <= 1000; i++) { ans = 0; for (j = 0; j < 26; j++) if (p[j] != 0) ans += (p[j] - 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
import java.util.Scanner; public class Banana { static String sol; static int n; private static int [] freq = new int[26]; public static void main(String[] args) { Scanner fin = new Scanner(System.in); String s = fin.nextLine(); n = fin.nextInt(); int 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> using namespace std; int N, M, T; int tb[127]; int main() { int i, j, k; char str[1005]; scanf("%s%d", str, &N); for (i = 0; str[i] != '\0'; i++) tb[str[i]]++; k = 0; for (i = 'a'; i <= 'z'; i++) if (tb[i]) k++; int st = 1, ed = 10000, mid, ans = -1; while (st <= ed) { 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
import java.io.*; import java.util.*; import java.lang.*; import java.util.function.*; public class Main { final static String fileName = ""; final static boolean useFiles = false; public static void main(String[] args) throws FileNotFoundException { InputStream inputStream; OutputStream 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
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); int l = sc.nextInt(); TreeMap<Character, Integer> counter = new TreeMap<Character, Integer>(); for (int i = 0; i < s.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
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353.; const long long INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7; const long long MOD2 = 998244353; const long long N = 5000 * 100 + 1; const long long N2 = 1000 * 1000 + 5; const long double PI = 3.14159265; const long long R = 250;...
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 int n; map<long long int, long long int> m; string s; bool check(long long int mid) { long long int i, j; long long int sum = 0; for (auto it = m.begin(); it != m.end(); it++) { sum = sum + ceil((it->second) * 1.00 / mid); } if (sum <= n) return 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
#include <bits/stdc++.h> using namespace std; void precompute(void) {} int main() { int t, n, len, i; char str[1032]; int fre[32], ans, avail, iter[32]; string ansstr; pair<int, int> top; set<pair<int, int> > S; precompute(); while (scanf("%s%d", str, &n) != EOF) { len = strlen(str); memset(fre,...
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 rdtsc() { long long tmp; asm("rdtsc" : "=A"(tmp)); return tmp; } inline int myrand() { return abs((rand() << 15) ^ rand()); } inline int rnd(int x) { return myrand() % x; } const int INF = (int)1e9 + 1; const long double EPS = 1e-9; const int maxl = (int)1e3...
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 a { static long mod = 1000000009; static ArrayList<Integer>[] g; public static void main(String[] args) throws IOException { //Scanner input = new Scanner(new File("input.txt")); //PrintWriter out = new PrintWriter(new File("output.txt")); input.init(...
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.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.util.ArrayList; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual sol...
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, cnt[26], k, dif; char s[2000]; bool u[26]; bool ok(int kk) { int need_n = 0; for (int i = 0; i < 26; i++) need_n += (cnt[i] + kk - 1) / kk; return (need_n <= n); } int main() { scanf("%s", s); scanf("%d", &n); dif = 0; for (int i = 0; s[i]; i++) { 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
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n; cin >> n; vector<int> freq(26, 0); for (int i = 0; i < (int)s.size(); ++i) freq[s[i] - 'a']++; int ans = -1; string s_ans = ""; for (int lf = 1, rt = 2000; lf <= rt;) { int mid = (lf + rt) >> 1; int total = 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.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Banana { public static void main(String[] args) throws IOException { br = new BufferedReader(new InputStreamReader(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.awt.Point; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.StringTokenizer; public class Abood3A { p...
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 = input() n = int(input()) d = {} for c in s: if c not in d: d[c] = 0 d[c] += 1 dcl = d.values() found = False for x in range(1,1001): if sum([(dc-1)//x+1 for dc in dcl]) <= n: found = True print(x) s = ''.join([key*((d[key]-1)//x+1) for key in sorted(d.keys()...
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.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
import java.util.*; import java.io.*; public class Main { public static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); t...
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.*; /** * @author pvasilyev * @since 8/3/13 */ 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 IOExceptio...
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, x[27], ct; char s[10001]; int main() { ct = 0; scanf("%s", s); scanf("%d", &n); for (int i = 0; s[i]; i++) x[s[i] - 'a']++; for (int i = 0; i <= 'z' - 'a'; i++) if (x[i] > 0) ct++; if (ct > n) printf("-1\n"); else { for (int 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
from collections import Counter def main(): s = input() l = int(input()) d = Counter(s) if len(d) > l: print(-1) return lo = 0 hi = 10000 while lo + 1 < hi: mid = (lo + hi) // 2 c = 0 for x in iter(d.values()): c += (x + mid - 1) // mid ...
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 setup(int value, string name) { string name_in = name + ".in"; string name_out = name + ".out"; freopen(name_in.c_str(), "r", stdin); if (value) freopen(name_out.c_str(), "w", stdout); } int main() { string str; std::cin >> str; map<char, int> bet; map<...
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 { void run() throws IOException { char[] str = nl().toCharArray(); int n = ni(), m = 26, k = 0; int[] a = new int[m]; for (char c : str) { a[c - 97]++; } for (int i : a) { if (i > 0) { k++; } } if (k > n) { pw.println(-1); ret...
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, t, ret, a[30]; char s[1005]; int solve(int k) { int req = 0; for (int i = (0); i < (26); i++) req += (a[i] + k - 1) / k; return req <= n; } int main() { scanf("%s%d", s, &n); for (int i = 0; s[i]; ++i) ++a[s[i] - 'a']; for (int i = (0); i < (26); i++) 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; int freq[500]; string calcular(int k, int n) { if (k == 0) return ""; 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...
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 oo = 1 << 30; const int NMAX = 1005; char s[NMAX], sol[NMAX]; int n, frecv[30], length; inline bool CHECK(int x) { int i, aux, rez = 0; for (i = 1; i <= 26; i++) if (frecv[i]) { aux = frecv[i] / x; if (frecv[i] % x != 0) aux++; rez += aux...
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 sys def dbg(was): if debug_mode: print 'DBG\t' + str(was) def solve(s, n): a = ord('a') z = ord('z') data = {} for char in s: dbg(char) data[char] = float(data.get(char, 0) + 1) data2 = [] for key in data.keys(): data2.append([key, data[key]]) ...
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 main() { string s; cin >> s; int n; cin >> n; int a[26], ans[26]; for (int i = 0; i < 26; i++) { a[i] = 0; ans[i] = 0; } for (int i = 0; i < s.length(); i++) a[s[i] - 'a']++; for (int i = 0; i < 26; i++) { if (a[i] != 0) { 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
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n; cin >> n; float arr[26] = {0}; set<char> s1; for (int i = 0; i < s.length(); i++) { s1.insert(s[i]); int x = s[i] - 97; arr[x]++; } if (s1.size() > n) { cout << "-1"; } else { string 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
#include <bits/stdc++.h> using namespace std; const int MAXPOW = 20; const int MAXA = 1048577; const int MAXN = 100009; const int MAXM = 100009; char s[1009]; int n; bool canSolve(int m, const vector<pair<int, char>>& cnt) { int need = 0; for (int i = 0; i < cnt.size(); ++i) { need += (cnt[i].first + m - 1) / 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; char s[1010]; int cnt[130] = {0}, cnt2[130] = {0}, ans[130] = {0}; double xxx[130]; int main() { int n; scanf("%s%d", s, &n); int len = strlen(s); for (int i = 0; i < len; ++i) ++cnt[s[i]]; int m = 0, n0 = n; for (int i = 'a'; i <= 'z'; ++i) if (cnt[i]) cnt2...
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, m, l = 0, a[33], b[33], S = 0, x; char s[1111]; int main() { cin >> s >> n; m = strlen(s); if (n >= m) { cout << "1" << endl; cout << s; for (int i = 0; i < n - m; i++) cout << "a"; return 0; } for (int i = 0; i < m; i++) a[s[i] - '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
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; const int inf = 1 << 29; const double eps = 1e-8; string s; int n; int vis[maxn]; bool check(int x) { int sum = 0; for (int i = 0; i < 26; i++) { if (vis[i]) sum += (vis[i] - 1) / x + 1; } return sum <= n; } int main() { int cnt = 0; 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
#include <bits/stdc++.h> using namespace std; map<char, long long int> mp; long long int n; bool check(long long int k) { long long int cnt = 0; for (char x = 'a'; x <= 'z'; x++) cnt += ceil((double)mp[x] / (double)k); if (cnt <= n) return 1; return 0; } long long int solve(long long int low, long long int high...
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 lcount[27]; bool works(int x) { int tot = 0; for (int i = 0; i < 26; i++) { if (lcount[i]) tot += (lcount[i] - 1) / x + 1; } return tot <= N; } int main() { cin >> s >> N; for (int i = 0; i < 27; i++) lcount[i] = 0; for (int i = 0; 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.util.*; public class P335A { private static class Letter implements Comparable<Letter> { char c; int total; int occu; public Letter(char c, int total, int occu) { this.c = c; this.total = total; this.occu = occu; ...
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; template <class T> inline T bigmod(T p, T e, T M) { long long md = M; if (e == 0) return 1; if (e % 2 == 0) { long long t = bigmod(p, e / 2, M); return (T)((t * t) % md); } long long bm = bigmod(p, e - 1, M); bm = (bm * (long long)p) % md; return (T)bm...
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 Banana { public static void main(String[] args) { Scanner input = new Scanner(System.in); int i,j,n,m,a,b,l,sum,c; char[] ss; String s,s1; while (input.hasNext()){ s = input.next(); sum = 0;s1 = "";c=0; n = input.nextI...
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 A5{ public static void main(String[] args){ Scanner in=new Scanner(System.in); int N,cnt; String str=in.nextLine(); char[] cstr=str.toCharArray(); Arrays.sort(cstr); N=in.nextInt(); cnt=0; int[] nc=new int[26]; for(int i=0;i<str.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.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class A { BufferedReader reader; StringTokenizer tokenizer; PrintWriter out; int[] cnt; int N; public void solve() throws IOException { cnt = ne...
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.math.BigInteger; import java.util.*; public class memSQL { public static void main(String[] args) throws IOException { new memSQL().run(); } int[] getCnt(String s) { int cnt[] = new int[300]; for(int i = 0; i < s.length(); ++i) cnt[s.charA...
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[1010], t[1010]; int a[27] = {0}, b[27] = {0}, n, m, x, y, l; int f(int k) { int s = 0; for (int i = 1; i <= 26; i++) if (a[i]) { s += a[i] / k; if (a[i] % k) s++; } return s; } int main() { scanf("%s", s); l = strlen(s); for (int i = 0; i < l; i++) a[s[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; const int mod = (int)1e9 + 7; char str[1010]; int a[30]; int n; bool can(int x) { int y = 0; for (int i = 0; i < 26; i++) y += a[i] / x + (a[i] % x > 0); if (y <= n) return true; return false; } int main() { scanf("%s", str); for (int i = 0; str[i]; i++) a[str[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
//package cf194; import java.util.*; import java.io.*; public class A2 { Scanner in; PrintWriter out; public void solve() throws IOException { String s = in.next(); int n = in.nextInt(); int[] a = new int[500]; for (int i = 0; i < s.length(); i++) { a[s.charAt(i)]++; } int l = 0; int r = 100000; ...
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; map<char, int> f; string s; char ch; bool solve(long long in) { int c = 0; for (auto a : f) { if (c > n) return 0; c += a.second / in + (a.second % in ? 1 : 0); } return c <= n; } int main() { ios::sync_with_stdio(false); cin >> s >> n; 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
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Reader; import java.io.UnsupportedEncodingException; import java.text.DecimalFormat...
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.text.DecimalFormat; import java.util.*; import java.awt.Point; public class Newbie { static InputReader sc = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) throws IOException { solver s = ne...
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 a[1005]; int t[26] = {0}; int func(int m) { int c = 0, i; for (i = 0; i < 26; i++) { if (t[i] != 0) { if (t[i] % m == 0) c += (t[i] / m); else c += (t[i] / m + 1); } } return c; } int main() { int s, n, i, j, c = 0, e, 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
#include <bits/stdc++.h> using namespace std; long long n, l, r, mid, hasil, ans, sz; map<char, long long> m; map<char, bool> b; vector<char> v; string ss, s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> s >> n; for (int i = 0; i < s.length(); i++) { if (b[s[i]] == false) { ...
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 import os import sys 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...
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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; public class Banana { static HashMap<Character, Integer>c; @SuppressWarnings("unchecked") public static 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
from math import ceil a=raw_input() n=int(raw_input()) s={} for i in a: if not i in s: s[i]=1 else: s[i]+=1 tk=False if len(s)>n: print -1 tk=True if not tk: s=sorted([(s[i],i) for i in s])[::-1] ss=[[i,j,1] for i,j in s] # print s t=[i for (j,i) in s] # print "".jo...
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 main() { ios_base::sync_with_stdio(false); string s; int n; cin >> s >> n; vector<int> hist(26); const int m = s.size(); for (int i = 0; i < m; ++i) { ++hist[s[i] - 'a']; } int nc = 0; for (int i = 0; i < 26; ++i) { if (hist[i] > 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
from math import ceil p = {i: 0 for i in 'abcdefghijklmnopqrstuvwxyz'} t = input() for i in t: p[i] += 1 p = {i: p[i] for i in p if p[i] > 0} n = int(input()) if len(p) > n: print(-1) elif len(t) > n: r = [[p[i], p[i], 1, i] for i in p] for i in range(n - len(p)): j = max(r) j[2] += 1 j[...
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; long long int n; map<long long int, long long int> m; string s; bool check(long long int mid) { long long int i, j; long long int sum = 0; for (auto it = m.begin(); it != m.end(); it++) { sum = sum + ceil((it->second) * 1.00 / mid); } if (sum <= n) return 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
from collections import Counter s = raw_input().strip() l = int(raw_input()) d = Counter(s) if len(d) > l: print -1 exit() lo = 0 hi = 10000 while lo + 1 < hi: mid = (lo + hi) / 2 c = 0 for x in d.itervalues(): c += (x + mid - 1) / mid if c > l: lo = mid else: hi = mid print hi ans = [] for x in d.iteritem...
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 Hash[28]; int main() { string input; cin >> input; int n; cin >> n; for (int i = 0; input[i]; i++) Hash[input[i] - 'a']++; for (int i = 1; i <= 1000; i++) { string result; int itr = 1; for (int j = 0; j < 26; j++) { int k = Hash[j] / i + bo...
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 MOD = 1000000007; template <class T> inline T tmin(T a, T b) { return (a < b) ? a : b; } template <class T> inline T tmax(T a, T b) { return (a > b) ? a : b; } template <class T> inline void add_max(T &a, T b) { if (b > a) a = b; } template <class T> inline ...
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 MAX_S = 1e3 + 20; int s_len; char s[MAX_S]; int n; map<char, int> ct, need; char ans[MAX_S]; bool check(int k) { int c = 0; for (auto it = ct.begin(); it != ct.end(); ++it) c += need[it->first] = (it->second + k - 1) / k; return c <= n; } 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
#include <bits/stdc++.h> using namespace std; const int N = 1005; char str[N]; int num[N], current[N]; struct Item { char c; int val; Item(char _c, int _val) : c(_c), val(_val) {} bool operator<(const Item& v) const { return val < v.val; } }; int main() { int n; int diff = 0; scanf("%s", str); scanf("%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 main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; string s, t; cin >> s >> n; map<char, int> mp; for (auto c : s) { mp[c]++; } if (n < mp.size()) { cout << -1; } else { auto check = [&](int x) { 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
s = input() n = int(input()) from collections import Counter c = Counter(s) out = Counter() contrib = Counter() for letter in c: out[letter] = 1 contrib[letter] = c[letter] sum_vals = sum(out.values()) from math import ceil from fractions import Fraction if sum_vals > n: print(-1) else: while sum_va...
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.util.*; import java.math.*; final public class Main implements Runnable { private static boolean local; public static void main(String[] args) { if (args.length > 0 && args[0].equals("-1")) { local = true; } new Thread(null, new Main(), "mainthread", 1 << 27).start(); } pub...
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[1010]; char ans[1010]; int n; int a[26]; int main() { scanf("%s", s); scanf("%d", &n); int len = strlen(s); for (int i = 0; i < len; i++) { a[s[i] - 'a']++; } int char_count = 0; for (int i = 0; i < 26; i++) { if (a[i] > 0) char_count++; } if (char_count > 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 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; int N; int main() { string str; while (cin >> str >> N) { int ch[109], ar[109]; memset(ch, 0, sizeof(ch)); memset(ar, 0, sizeof(ar)); for (int i = 0, _n = str.size(); i < _n; i++) { ar[str[i] - 'a']++; } int rex = 0, rey = 0; for (int 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; ifstream fin("banana.in"); ofstream fout("banana.out"); string s, s2; int a, b, x, f[30], ct, ok, mx, p, f2[30], q[30]; int main() { int i; cin >> s; cin >> x; for (i = 0; i < s.size(); i++) { if (f[s[i] - 'a'] == 0) ct++; f[s[i] - 'a']++; } if (ct > x) ...
CPP