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; string ans = ""; bool solve(map<char, int> &mp, int tot, int len) { string s = ""; for (auto i : mp) { int a = (i.second / tot + (i.second % tot > 0)); len -= a; while (a--) s += i.first; } if (len >= 0) { ans = s; return true; } return 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
import java.util.*; import java.io.*; public class A { public static boolean bg = true; public static BR in = new BR(); public static void main(String[] args) throws Exception { char[] l1 = in.nx().toCharArray(); int n1 = in.ni(); int[] count = new int[26]; for (char e: l1){...
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
#!/usr/bin/env python from __future__ import division, print_function import os import sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip from collections import Counter import heapq as pq from 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; char str[1005]; int N; int cword[30]; int main() { scanf("%s", str); scanf("%d", &N); int i; int type = 0; for (i = 0; str[i] != '\0'; i++) { if (cword[(int)(str[i] - 'a' + 1)] == 0) type++; cword[(int)(str[i] - 'a' + 1)]++; } if (N < type) printf(...
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 data() { freopen("data.in", "r", stdin); freopen("data.out", "w", stdout); } char s[1100]; int su[27]; int k; int jd(int n) { int cnt = 0; for (int i = 0; i < (26); ++i) { cnt += (su[i] + n - 1) / n; } if (cnt <= k) return 1; else 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
#include <bits/stdc++.h> using namespace std; const int N = 100500; const int inf = 1 << 30; char s[1010]; int cnt[26], n; int main() { cin >> s >> n; for (int i = 0; s[i]; i++) cnt[s[i] - 'a']++; for (int t = 1; t <= 1000; t++) { int sum = 0; for (int i = 0; i < 26; i++) sum += (cnt[i] + t - 1) / 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; string s, ans; int n, k, lo, hi; bool sat(int x) { int occ[26], ret = 0; memset(occ, 0, sizeof(occ)); int len = s.length(); for (int i = 0; i < len; i++) occ[s[i] - 'a']++; for (int i = 0; i < 26; i++) ret += ((occ[i] + x - 1) / x); return ret <= 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; int org[26], req[26], y, n, ans, maxi; int ansr(int l, int r) { if (l >= r) return l; int mid = l + (r - l) / 2; int o = 0; for (int i = 0; i < 26; i++) if (org[i] != 0) { o += org[i] / mid; if (org[i] % mid != 0) o += 1; } if (o > n) retur...
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 = 1010; char str[N]; int cnt[26]; int ans[26]; int f(int i) { return cnt[i] / ans[i] + (bool)(cnt[i] % ans[i]); } int main() { scanf("%s", str); int n; scanf("%d", &n); memset(cnt, 0, sizeof(cnt)); int len = strlen(str); for (int i = 0; i < len; 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 num[30]; char str[1000010]; int out[30]; int limit; bool ok(int mid) { for (int i = 0; i < 26; i++) { if (num[i] == 0) continue; out[i] = num[i] / mid; if (num[i] % mid != 0) out[i]++; } int cnt = 0; for (int i = 0; i < 26; i++) { if (num[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
#include <bits/stdc++.h> using namespace std; int main() { int d[256] = {0}, n; string s; cin >> s >> n; for (int i = 0; i < int(s.size()); i++) d[s[i]]++; int cntDif = 0; for (char c = 'a'; c <= 'z'; c++) if (d[c]) cntDif++; if (cntDif > n) puts("-1"); else for (int ans = 1; ans <= 10000; 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
s=raw_input() n=input() l=[0]*26 ans='' for i in s: if i not in ans: ans+=i else: l[ord(i)-97]+=1 if len(ans)>n: print -1 elif len(s)==n: print 1 print s else: chk=n-len(ans) while 1: if chk==0 or sum(l)==0:break mc=mi=0 for i in range(26): ...
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 NMax = 1000001; const int cntTree = 262145; const long double eps = 1e-9; const double PI = 3.141592653589793238462; const int MD = (int)1e9 + 7; FILE *stream; string s; int n; int c[27], c1[27]; int main() { cin >> s >> n; for (int i = 0; i < (int)(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
#include <bits/stdc++.h> using namespace std; int dir[4][2] = {-1, 0, 0, 1, 0, -1, 1, 0}; char s[1010]; int cnt[30] = {0}; int n; bool can(int mid) { int k = 0; for (int i = 0; i < 26; i++) { if (cnt[i] == 0) continue; int t = cnt[i] - mid; if (t > 0) { k += (t + mid - 1) / mid; } } 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class CF335A { static final int CHARS = 26; public static void main(String[] args) throws IOException { FastScanner sc = new FastScanner(); ...
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 collections import Counter def main(): s = raw_input().strip() l = int(raw_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 d.itervalues(): c += (x + mid - 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
import java.io.IOException; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class ProblemA { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); String s = in.next(); int n = in.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
#include <bits/stdc++.h> using namespace std; const double PI = 2 * acos(0); const double EPS = 1e-9; const long long oo = 1e18; const long long MOD = 1e9 + 7; const int N = 1e3 + 5; const int AL = 26; char in[N]; int freq[AL], freq2[AL]; int main() { int n; scanf("%s%d", &in, &n); string s = in; int cnt = 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
//package prac; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class MA { InputStream is; PrintWriter out; String INPUT = ""; void solve() { char[] s = ns().toChar...
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,n,q,a=input(),int(input()),{},"" for i in s:q[i]=[q[i][0]+1,1]if i in q else [1,1] if len(q)>n:print(-1) else: for i in range(n-len(q)): o=0 for j in q: m=(q[j][0]+q[j][1]-1)//q[j][1] if m>o:o,w=m,j q[w][1]=q[w][1]+1 o=0 for i in q: a+=i*q[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.util.Scanner; public class Main { public static void main(String args[]){ Scanner in = new Scanner(System.in); char c[] = in.next().toCharArray(); int n = in.nextInt(); int a[] = new int[26]; for (int i = 0; i < c.length; i++) { a[c[i] - '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.util.*; public class maximus { public static void main(String [] args){ Scanner in=new Scanner(System.in); String str=in.next(); int n=in.nextInt(); int array[]=new int[26]; for(int i=0;i<str.length();i++)array[str.charAt(i)-97]++; int high=1001; int low=0; int cnt=0; for(int i=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
#include <bits/stdc++.h> using namespace std; char s[1024]; int n; int cnt[26], kind; int mem[26]; char res[1024]; bool chk(int sz) { for (int i = 0; i < 26; i++) mem[i] = cnt[i]; int ch = 0; for (int i = 0; i < n; i++) { while (ch < 26 && mem[ch] <= 0) ch++; if (ch == 26) res[i] = 'z'; else { ...
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 solved[26][1003]; char s[1003]; int C[26], M[26][1003], P[26][1003]; int DP(int i, int j) { if (i == 26) return 0; if (solved[i][j]) return M[i][j]; solved[i][j] = true; if (!C[i]) return M[i][j] = DP(i + 1, j); M[i][j] = 2147483647; for (int k = 1, r; 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; int dx[] = {0, 0, -1, 1}; int dy[] = {-1, 1, 0, 0}; char s[200010]; int sum[333], t[333]; int n, m; bool check() { int time = 0; for (int i = ('a'); i <= ('z'); ++i) time += (sum[i] > 0); return time <= n; } bool ok(int limit) { memset(t, 0, sizeof(t)); int time =...
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,n,q,a=input(),int(input()),{},"" for i in s:q[i]=[q[i][0]+1,1]if i in q else [1,1] if len(q)>n:print(-1) else: for i in range(n-len(q)): o=0 for j in q: m=(q[j][0]+q[j][1]-1)//q[j][1] if m>o:o,w=m,j q[w][1]=q[w][1]+1 for i in q:a+=i*q[i][1] o=0 for i in ...
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> #pragma comment(linker, "/Stack:256000000") using namespace std; const int INF = (int)1e9; const double EPS = 1e-9; const int MOD = 1e9 + 7; int solve(); int gen(); bool check(); int main() { solve(); return 0; } int solve() { cin.tie(0); cin.sync_with_stdio(0); string s; int n; 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; string s; int n; vector<int> cnt; bool comp(int k) { int need = 0; for (int i = 0; i < 30; i++) { if (cnt[i] == 0) continue; need += (cnt[i] - 1) / k + 1; } return need <= n; } int main() { std::ios::sync_with_stdio(false); cin.tie(NULL); int n_case; ...
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 from heapq import heappushpop def main(): cnt, n = Counter(input()), int(input()) if n < len(cnt): print(-1) return h = list((1 / v, 1, c) for c, v in cnt.most_common()) res = list(cnt.keys()) _, v, c = h.pop(0) for _ in range(n - len(cnt)): ...
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.util.Scanner; public class A335 { public static void main(String[] args) { Scanner in = new Scanner(System.in); char[] S = in.next().toCharArray(); int N = in.nextInt(); int[] stat = new int[26]; for (char c : S) { stat[c-'a']++; } in...
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.*; import javax.sound.midi.Synthesizer; public class Problem5 { static ArrayList<Integer> primes; static void sieve(int N) { boolean[] isComposite = new boolean[N]; primes = new ArrayList<Integer>(N / 10); for(int i = 2; i < N; ++i) if(!isComposite[i]) { prime...
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.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeMap; public class Main { public st...
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 sheets{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); int n = sc.nextInt(); int low =0; int high=100000; TreeMap<Character,Integer> map = new TreeMap<>(); for(int i=0;i<s.length();i++){ map.put(s.charAt(i),map.getOr...
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> long i, j, k, x, r, y, n, f[150], z, R; char s[1002], a[1002]; int main() { scanf("%s", s); scanf("%ld", &n); for (i = 0; s[i]; i++) f[s[i]]++; for (i = 'a'; i <= 'z'; i++) if (f[i]) j++; if (j > n) { printf("-1\n"); return 0; } x = 1; y = 1000000; dos: z = (x + y)...
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 comment(linker, "/STACK:16777216") using namespace std; int n; string s; int cnt[2100]; bool check(int m) { int x = n; for (int i = ('a'), _b = ('z'); i <= _b; i++) { x -= cnt[i] / m + (cnt[i] % m > 0); } return x >= 0; } int find() { int l = 1, r = 1000, res = 0; while ...
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[27]; int num[27]; int main() { string s; int k, mx; int ans; int n; string t; int m; cin >> s >> n; for (int i = 0; i < s.size(); ++i) { ++cnt[s[i] - 'a']; } m = 0; for (int i = 0; i < 26; ++i) { if (cnt[i]) ++m; } if (n < 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; long long i, j, n, c[1223456], d[11], b[223465], a[456123], e, l, r, s, t, tt, k, x, y, z, m; string p, q, du, qq; pair<long long, long long> u[132456], w[123456]; int main() { cin >> p >> n; l = p.size(); for (i = 0; i < l; i++) { if (a[p[i] - 'a'] == 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
#include <bits/stdc++.h> using namespace std; long long prr[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, ...
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 num[1500]; int lets; int n, len; int l, r, m; bool ok(int x) { int cur = 0; for (char c = 'a'; c <= 'z'; c++) if (num[c] > 0) { if (num[c] % x == 0) cur += num[c] / x; else cur += (num[c] / x) + 1; } if (cur > 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
import java.util.*; public class A { static int result = -1; public static int ceiling(int n,int m){ int r = n % m; if(r == 0)return n/m; return n / m +1; } /** * @param args */ @SuppressWarnings("unchecked") 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
import java.io.*; import java.util.*; public class A { BufferedReader in; StringTokenizer st; PrintWriter out; String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine()); return st.nextToken(); } int nextInt() throws Exception { return Integer...
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.util.Arrays; import java.util.StringTokenizer; import java.util.TreeSet; public class Banana { public static boolean can(int []a,int n,int len) { int needed=0; for(int x:a) needed+=(...
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 CodeForces { public static void main(String[] args) throws Exception{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String s = in.readLine(); int n = Integer.parseInt(in.readLine()); numStamp(s, n); } public static void numStam...
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 charcount[26]; int res[26]; int n, tempcount, tnum; char c; int main() { for (int i = 0; i < 1024; ++i) { scanf("%c", &c); if (!(c - 'a' >= 0) && (c - 'a' < 26)) { break; } ++charcount[c - 'a']; } scanf("%d", &n); 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; template <typename T> inline string toString(T a) { ostringstream os(""); os << a; return os.str(); } template <typename T> inline long long toLong(T a) { long long res; istringstream os(a); os >> res; return res; } template <typename T> inline T SQ(T a) { 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
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; public class A { public static void main(String[] args) throws Exception{ InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); String s = in.next...
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 MAXN = 1010; char B[MAXN]; int C[26]; int main() { scanf("%s", B); int l = strlen(B); for (int i = 0; i < l; i++) C[B[i] - 'a']++; int n; scanf("%d", &n); for (int k = 1; k <= l; k++) { int s = 0; for (int i = 0; i < 26; i++) s += (C[i] + k - 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; int main() { char C[1047]; int n; scanf("%s %d", C, &n); string s = C; vector<int> P, V; P.resize(300, 0); V.resize(300, 0); for (int i = 0; i < (s.length()); i++) P[s[i]]++; int poc = 0; for (int i = 0; i < (300); i++) { if (P[i] == 0) continue; ...
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; map<char, int> mp; for (auto i : s) mp[i]++; for (int i = 1; i <= 1000; i++) { string ans = ""; for (auto c : mp) { int x = ceil(1.0 * c.second / i); for (int i = 0; i < x; i++) ans += c.fir...
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.*; public class CF3 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out)); String s = br.readLine(); int n = Integer...
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[1010]; int n; int cnt[26]; bool check(int x) { int len = 0; for (int i = 0; i < 26; ++i) len += (cnt[i] + x - 1) / x; return len <= n; } int main() { scanf("%s%d", str, &n); for (int i = 0; str[i]; ++i) cnt[str[i] - 'a']++; int c = 0; for (int 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
#include <bits/stdc++.h> using namespace std; int main() { int q, w, e, r, t, c, s[26]; char a[1001]; cin >> a >> q; for (w = 0; w < 26; w++) s[w] = 0; for (w = 0; a[w]; w++) s[a[w] - 97]++; w = 1001; e = 512; while (e) { r = w - e; if (r > 0) { t = q; for (c = 0; c < 26; 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.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeMap; import java.util.TreeSet; public class C_1 { public static void main(String[] args) throws IOException { Sca...
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; public class Banana { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); int n = Integer...
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 A { void solve() throws IOException { String s = next(); int n = nextInt(); int[] cnt = new int[26]; for (int i = 0; i<s.length(); i++) { cnt[s.charAt(i) - 'a']++; } for (int i = 1; i<=s.length(); i++) { int[] must = new int[26]; int calc = 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
#include <bits/stdc++.h> using namespace std; const int force = 27; const int inf = 1000 * 1000 * 1000; string s; int n, a[force], b[force]; int main() { cin >> s; cin >> n; for (int i = 0; i < force; i++) { a[i] = 0; b[i] = 0; } int dif = 0; string ans = ""; for (int i = 0; i < s.length(); 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; void solve() { string s; string s1; map<char, double> m1; map<char, double> m2; map<char, double> m3; double temp; char c; long long n, i, max, index; cin >> s; cin >> n; for (i = 0; i < s.size(); i++) { m2[s[i]]++; m1[s[i]]++; } if (m1.siz...
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 = int(raw_input()) d = dict() for c in s: d[c] = d.get(c, 0) + 1 if len(d.keys()) > n: print -1 else: l = 1 r = len(s) while r - l > 0: m = (r + l) / 2 lst = [] sm = 0 for k in d.keys(): cnt = d[k] / m + (1 if d[k] % m > 0 else 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
#!/usr/bin/env python from collections import Counter from operator import itemgetter s = raw_input() n = int(raw_input().strip()) if len(set(s)) > n: print '-1' exit() chars = Counter(s) def generate_paper(n, count, chars): if count <= 0: return '' paper = [] paper_size = n for 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; int main() { char name[1050]; int A[100]; int c, n, k, num, v; scanf("%s", name); scanf("%d", &n); fill(A, A + 27, 0); for (int(i) = 0; (i) < (strlen(name)); (i)++) { A[int(name[i] - 'a')]++; } c = 0; for (int(i) = 0; (i) < (26); (i)++) if (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
import java.io.*; import java.util.*; public class Main { public static class Pair implements Comparable<Pair> { public char c; public int f; public Pair(char c, int f) { this.c = c; this.f = f; } public int compareTo(Pair pair) { if (this...
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[255]; string s; bool check(int l) { int nn = n, t; for (char ch = 'a'; ch <= 'z'; ch++) { if (cnt[ch] % l == 0) t = cnt[ch] / l; else t = cnt[ch] / l + 1; nn -= t; if (nn < 0) return 0; } return 1; } string calc(int l) { stri...
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.util.*; public class Banan { public static class Letter implements Comparable<Letter>{ public Letter(char c, int count){ this.letter = c; this.stickCount = 1; this.str�ount = count; } char letter; ...
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 mas[26]; string s; int main() { int n; cin >> s >> n; for (int i = 0; i < s.length(); i++) mas[s[i] - 'a']++; int mini = 0; for (int i = 0; i < 26; i++) if (mas[i] != 0) mini++; if (mini > n) { cout << -1 << endl; return 0; } for (int col = 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.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.Locale; import java.util.StringTokenizer; import static java.util.Arrays.deepToString; public class A { static int doit(int[] cnt, int[] have, boolean finish) { for (int i = 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
import java.util.*; import java.io.*; import java.nio.*; import java.nio.channels.*; public class Main { static BufferedReader reader; static StringTokenizer tokenizer; static PrintWriter out = new PrintWriter(Channels.newWriter(Channels.newChannel(System.out), "US-ASCII") ); static int CHARS = 'z'-'a' +1; ...
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 s[2000]; int n; map<char, int> counter; map<char, int> repeat; int main() { scanf("%s", s); scanf("%d", &n); int len = strlen(s); for (int i = 0; i < len; i++) { counter[s[i]] += 1; repeat[s[i]] = 1; } if (n < counter.size()) { puts("-1"); 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
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class A { static StringTokenizer st; static BufferedReader in; static Prin...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) lst = list(map(int,input().split())) a = list(zip(lst,lst[1:])) record = [] for x in a: s,e = min(x[0],x[1]),max(x[0],x[1]) for y in record: if y[0]<s<y[1]<e or s<y[0]<e<y[1]: exit(print("yes")) record.append((s,e)) print("no")
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) a = [int(x) for x in input().split()] x = [] for i in range(n - 1): x.append(sorted([a[i],a[i + 1]])) #print(x) for i in range(n - 1): for j in range(i + 2, n - 1): if (x[i][0] > x[j][0] and x[i][0] < x[j][1] and (x[i][1] > x[j][1] or x[i][1] < x[j][0])) or (x[i][1] > x[j][0] and x[i][1...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; int a[1005]; int i, j; while (scanf("%d", &n) != EOF) { for (i = 0; i < n; i++) scanf("%d", &a[i]); for (i = 0; i < n - 1; i++) { int l = a[i], r = a[i + 1]; if (l > r) swap(l, r); for (j = 0; j < n - 1; j++) { i...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n=int(input()) l=[int(x) for x in input().split()] a=[] for i in range(n-1): a.append((min(l[i], l[i+1]), max(l[i], l[i+1]))) for i in a: for j in a: if i[0]<j[0]<i[1]<j[1] or j[0]<i[0]<j[1]<i[1]: print("yes") exit() print("no")
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int l, r, ll, rr, n, arr[1009]; cin >> n; for (int i = 0; i < n; i++) cin >> arr[i]; for (int i = 0; i + 1 < n; i++) { l = min(arr[i], arr[i + 1]); r = max(arr[i], arr[i + 1]); for (int j = i + 2; j + 1 < n; j++) { ll = min(arr[j], arr...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import sys input = lambda: sys.stdin.readline().strip("\r\n") n = int(input()) ls = list(map(int, input().split())) for i in range(n-1): for j in range(n-1): w, x = sorted([ls[i], ls[i+1]]) y, z = sorted([ls[j], ls[j+1]]) if w < y < x < z or y < w < z < x: print('yes') ...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; const int MAXN = 1030; int x[MAXN]; int main() { int n; cin >> n; for (int i = 0; i < (n); ++i) cin >> x[i]; for (int i = 0; i < (n - 1); ++i) { for (int j = i + 2; j <= (n - 2); ++j) { int a(x[i]), b(x[i + 1]); int c(x[j]), d(x[j + 1]); if (a ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) seq = list(map(int, input().split())) if n == 1: print("no") exit(0) pairs = [] cur = [-1, seq[0]] fail = False for i in range(1, len(seq)): cur[0], cur[1] = cur[1], seq[i] pairs.append([min(cur), max(cur)]) for x1, x2 in pairs: if not fail: for x3, x4 in pairs: if (x1 != x3 or x2 != x4) ...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; bool compare(const pair<int, int>& i, const pair<int, int>& j) { return i.first < j.first; } void solve() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; int a[n]; for (int i1 = 0; i1 < n; i1++) { cin >> a[i1]; } for (in...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int a[1111]; int main() { int n, i, j; int themax1, themin1; int themax2, themin2; int flag = 0; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; if (n <= 2) flag = 0; else { for (i = 2; i < n - 1; i++) { themax2 = max(a[i], a[i + 1]); them...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.Scanner; /** * Created by tdph5945 on 2016-06-18. */ public class DimaAndContinuousLine { public static void main(String... args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(), first, second, lfirst, lsecond; int[] arr = new int[n]; for (in...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) seq = list(map(int, input().split())) if n == 1: print("no") exit(0) pairs = [] cur = [-1, seq[0]] fail = False for i in range(1, len(seq)): cur[0], cur[1] = cur[1], seq[i] if cur[1] < cur[0]: pairs.append([cur[1], cur[0]]) else: pairs.append(cur[:]) #print(pairs) for x1, x2 in pairs: if...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.Scanner; public class DimaAndContinuousLine { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; for(int i=0; i<n; i++){ arr[i] = sc.nextInt(); } boolean flag = false; ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n,l=int(input()),list(map(int,input().split())) for i in range(n-1): for j in range(n-1): a,b,c,d=sorted([l[i],l[i+1]])+sorted([l[j],l[j+1]]) if a<c<b<d: exit(print('yes')) print('no')
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.Scanner; /** * Created with IntelliJ IDEA. * User: samir * Date: 10/25/13 * Time: 11:46 PM * To change this template use File | Settings | File Templates. */ public class A { public static boolean intersects(int[] n) { for(int i = 1; i < n.length; ++i) { int seg0_start = ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) lst = list(map(int,input().split())) for i in range(n-1): for j in range(i+1,n-1): # Check if the start of the first semi circle is smaller than the second one # and the end of the frist semi circle is also small the second one # It it's true then there is an intersection ...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n=int(input()) arr=[int(i) for i in input().split()] if n==2 or n==1: print("no") exit() l=[[arr[0],arr[1]],[arr[1],arr[2]]] for i in range(2,n-1): for j in range(i): x= abs(abs(l[j][0]-l[j][1])/2 - abs(arr[i]-arr[i+1])/2) < abs((l[j][0]+l[j][1])/2 - (arr[i]+arr[i+1])/2 ) < abs(l[j][0]-l[j][1])/2 + ...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
''' Created on Oct 31, 2013 @author: Ismael ''' def main(): input() l = list(map(int,input().split())) #l = [0,10,5,15] #l = [0,15,5,10] if(len(l)<=3): print("no") return xMin = min(l[0],l[1]) xMax = max(l[0],l[1]) for i in range(2,len(l)-1): if(l[i]<=xMin or l...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n = int(input()) x = [int(x) for x in input().split()] list11 = [] ans = 'no' for i in range(n-1): if x[i]<x[i+1]: list11.append([x[i],x[i+1]]) else: list11.append([x[i+1],x[i]]) list1 = sorted(list11,key=lambda x:x[1]) for i in range(len(list1)): for e in range(i,len(list1)): if i==...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public String isIntersection(int n, int[] points) { if (n == 0 || n == 1) return "no"; int temp; for (int i = 0; i < points.length-1; i++) { int x1=points[i]; int x2=points[i+1]; ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.Scanner; public class DimaContinousLine { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] ar = new int[n]; for (int i = 0; i < n; i++) { ar[i] = sc.nextInt(); } boolean inter = false; for (int i = 0; i < ar.length; i++) { ...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
def intersect(p1,p2): if (p2[0] < p1[1] and p2[0] > p1[0] and p2[1] > p1[1]) or (p2[1] < p1[1] and p2[1] > p1[0] and p2[0] < p1[0]): return True return False def check(points): for x in range(len(points)): for i in range(x + 1,len(points)): if intersect(points[x],points[i]): ret...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int const Max = 1111; int n; int x[Max]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> x[i]; bool ans = true; for (int i = 1; i < n; i++) { bool f1 = false; bool f2 = false; for (int j = i + 2; j <= n; j++) { int Min, Max; Min = ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int l = INT_MAX; int h = INT_MIN; string ans = "no"; if (n > 3) { vector<pair<int, int>> arr; int a, b; cin >> a >> b; if (a < b) arr.push_back({a, b}); ...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main extends PrintWriter { BufferedReader in; StringTokenizer stok; final Random rand = new Random(31); final int inf = (int) 1e9; final long linf = (long) 1e18; boolean intersect(int x1, int y1, int x2, int y2...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int n, arr[1000]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> arr[i]; bool ans = false; for (int i = 0; i < n - 1; i++) { int l1 = min(arr[i], arr[i + 1]); int r1 = max(arr[i], arr[i + 1]); for (int j = 0; j < n - 1; j++) { int l2 = m...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
n=int(input()) ar=map(int,raw_input().split()) l=[] for _ in xrange(n-1): l.append([]) for i in xrange(n-1): l[i].append((ar[i+1]+ar[i])/2.0) l[i].append(abs(ar[i+1]-ar[i])/2.0) flag=1 for i in xrange(n-1): for j in range(i+1,n-1): c1=l[i][0] c2=l[j][0] r1=l[i][1] r2=l[j]...
PYTHON
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int p1; cin >> p1; int p2; cin >> p2; vector<pair<int, int> > v; int p = p2; v.push_back(make_pair(p1, p2)); for (int i = 1; i < n; i++) { int t; cin >> t; for (int i = 0; i < v.size(); i++) { int l1 = v[i]...
CPP
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.util.*; import java.io.*; public class Dima_and_Continuous_Line { public static void main(String args[]) throws Exception { BufferedReader f=new BufferedReader(new InputStreamReader(System.in)); int runs=Integer.parseInt(f.readLine()); interval[] arr=new interval[runs-1]; StringTokenizer st=new St...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; public class Solution { public static void main(String[] args) throws IOException { InputStr...
JAVA
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
""" let one arc is s1-s2 then it cuts another arc s3-s4 if 1. s1<s3<s2<s4 OR 2. s3<s1<s4<s2 for each arc, check if it cuts any of the other arcs """ n = int(input()) x = [] mp = map(int,input().split()) for k in mp: x.append(k) res = False #means that do not cut for i in range(n-1): s1 = min(x[i],x[i+1]) ...
PYTHON3
358_A. Dima and Continuous Line
Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework. The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them...
2
7
import sys n = int(raw_input()) L = list(map(int, raw_input().split(' '))) Lft =[] Rt =[] if len(L) <=3: print 'no' else : for i in range(n): tt = i+1 if tt != n: if L[i] < L[tt]: Lft.append(L[i]) Rt.append(L[tt]) else : ...
PYTHON