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
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n=int(input()) s=[int(c) for c in input().split()] s.sort() s.reverse() ans=1 def f(a): i=0 b=True while i<len(a) and b: if a[i]<len(a)-i-1: b=False return b i+=1 return b while True: p=[[] for i in range(ans)] i=0 while i<n: p[i%ans].append(...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n = int(input()) arr = list(map(int,input().split())) arr.sort() unq, ans, req = set(arr), 1, 0 for ele in unq: count = arr.count(ele) req += count if req//(ele+1) != req/(ele+1): ans = max(1 + req//(ele+1), ans) else: ans = max(req//(ele+1), ans) print(ans)
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n=input() d=sorted(map(int,raw_input().split())) for k in range(1,101): b=1 for i in range(n): if d[i] < i/k: b=0 if b: print k exit(0)
PYTHON
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import java.util.Map.Entry; public class zz{ public static void main(String[] args) throws IOException{ MScanner sc = new MScanner(System...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n, arr[200]; while (cin >> n) { int ans = 0, arr1[200]; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); for (int i = 0; i < n; i++) { bool flag = 0; for (int j = 0; j < ans; j++)...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
R=lambda:map(int,raw_input().split()) n = input() a = R() a.sort() res = 1 l = [[a[0]]] for i in range(1, n): ins = False for j in range(len(l)): if len(l[j]) <= a[i]: l[j].append(a[i]) ins = True break if not ins: l.append([a[i]]) print len(l)
PYTHON
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int data[100]; int freq[101]; int min(int a, int b) { if (a < 0) return 0; if (b < 0) return 0; if (a < b) return a; return b; } int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", data + i); for (int i = 0; i < 101; i++) freq[i] = 0...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } const int INF = 1 << 29; inline int two(int n) { return 1 << n; } inline int test(int n, int b) { return (n >> b) & 1; } inline void set_bit(int& n, int b) { n |= two(b); } inline void unset_bit(int& n, int b...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int a[110]; int vis[110]; int n; int main() { int i, j; while (scanf("%d", &n) != EOF) { memset(vis, 0, sizeof(vis)); for (i = 1; i <= n; i++) { scanf("%d", &a[i]); } sort(a + 1, a + n + 1); int ans = 0; int cnt = 0; for (i = 1; i <= n;...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v1, v2; int n, ctr, counter, flag; cin >> n; v1.resize(n); v2.resize(n); for (int i = 0; i < n; i++) { cin >> v1[i]; v2[i] = 0; } sort(v1.begin(), v1.end()); counter = 0; while (1) { flag = 0; for (int i = 0; i < ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush # from math import * from collections import defaultdict as dd, deque, Counter as C from itertools import combinations as comb, permutations as perm from bisect import bisect_left as bl, bisect_right as br, bisect...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import sys #input=sys.stdin.buffer.readline t=1 mod=10**9+7 for __ in range(t): #a=[] n=int(input()) #n,m=map(int,input().split()) l=list(map(int,input().split())) l.sort() cnt=0 maxi=0 ans=0 # print(l) while cnt<n: cnt1=0 for i in range(n): if l[i]!...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.*; import java.util.*; public class CFR2283 { public static void main (String[] args) { Scanner sc = new Scanner (System.in); PrintStream op = System.out; int N = sc.nextInt(); int[] X = new int [N]; int[] pile = new int [N]; for (int i = 0; i < N; i++) X[i] = sc.nextInt(); Arrays.sort...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; const double PI = 2.0 * acos(0.0); const double EPS = 1e-9; int cases = 1; double getdist(pair<int, int> a, pair<int, int> b) { return sqrt(pow(a.first - b.first, 2) + pow(a.second - b.second, 2)); } void read(void) { return; } int n, box[105]; int main() { int test; ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n=int(input()) ar=list(map(int,input().strip().split(' '))) ar.sort() i=0 li=list() cnt=[0]*(101) for i in ar: cnt[i]+=1 for i in range(101): if cnt[i]==0: continue if len(li)==00: x=(i+1) li.extend([x]*(cnt[i]//x)) if cnt[i]%x!=0: li.append(cnt[i]%x...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#!/usr/bin/env python import os import sys from io import BytesIO, IOBase #from bisect import bisect_left as bl #c++ lowerbound bl(array,element) #from bisect import bisect_right as br #c++ upperbound br(array,element) def main(): n=int(input()) a=list(map(int,input().split(" ")...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.*; import java.math.*; import java.util.*; /** * * @author Saju * */ public class Main { private static int dx[] = { 1, 0, -1, 0 }; private static int dy[] = { 0, -1, 0, 1 }; private static final long INF = Long.MAX_VALUE; private static final int INT_INF = Integer.MAX_VALUE; ...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 100 + 10; int n, a[MAXN], mark[MAXN], l; void input() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); } int main() { input(); int l = 0; bool chek; for (int i = 0; i < n; i++) { chek = true; for (int j = ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputStream input...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int x[101]; int towers = 0; int n; cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; sort(x, x + n); int count = 0; while (count < n) { int cur = 0; for (int i = 0; i < n; i++) { if (x[i] >= cur) { count++; cur++; ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.*; import java.util.*; /* @author Mikhail Linkov */ public class TaskC { private final static int MAX = 10000001; public void solve() { InputReader reader = new InputReader(System.in); PrintWriter writer = new PrintWriter(System.out, true); int n = reader.nextInt()...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
/* Keep solving problems. */ import java.util.*; import java.io.*; public class CFA { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; final long MOD = 1000L * 1000L * 1000L + 7; int[] dx = {0, -1, 0, 1}; int[] dy = {1, 0, -1, 0}; void solve() throws IOException ...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n=int(input()) a=list(map(int,input().split())) a.sort() visited=[0]*n i=0 res=0 while i<n: if visited[i]==0: visited[i]=0 j=i c=0 while j<n: if a[j]>=c and visited[j]==0: visited[j]=1 c += 1 j+=1 res+=1 i += 1 pr...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int piles[105]; int main() { int n; cin >> n; vector<int> A(n); for (int i = 0; i < n; ++i) cin >> A[i]; sort(A.begin(), A.end()); for (int i = 0; i < n; ++i) { bool flag = false; for (int j = 0; j <= A[i]; ++j) if (piles[j]) { --piles[j]; ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int mm[105] = {0}; bool vis[105] = {0}; int main() { int n, ans = 0, m; cin >> n; m = n; for (int i = 0; i < n; i++) { cin >> mm[i]; } sort(mm, mm + n); int we = 0; while (m) { for (int i = 0; i < n; i++) { if (!vis[i] && mm[i] >= we) { ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
# import sys # sys.stdin = open('input.txt', 'r') # sys.stdout = open('output.txt', 'w') # t=int(input()) t=1 while t: t-=1 n=int(input()) l=list(map(int,input().split())) l.sort() ans=1 for i in range(n): if(l[i]<i//ans): ans+=1 print(ans)
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.*; import java.lang.reflect.Array; import java.math.*; import java.text.DecimalFormat; import java.util.*; public class Main { private static int n; private static int [] A; private static boolean can(int m) { int [] R = new int[m]; for (int i = 0;i < m;i++) R...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
def main(): mode="filee" if mode=="file":f=open("test.txt","r") #f.readline() #input() get = lambda :[int(x) for x in (f.readline() if mode=="file" else input()).split()] [n]=get() a=get() a.sort() p=[[]] p[0].append(a[0]) for i in a[1:]: p=sorted(p,key = lambda x:len...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; import java.util.Scanner; /** * Created by PalmZE on 13.11.2015. */ public class Task388A { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); Arr...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n,ans,tot=input(),0,0 a=sorted(map(int, raw_input().split())) taken = [False] * n while tot < n: curr=0 for i in range(n): if (not taken[i]) and a[i] >= curr: taken[i] = True curr += 1 tot += curr ans += 1 print ans
PYTHON
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 200; int a[N]; bool used[N]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); int cnt = 0; int ans = 0; while (cnt != n) { int st = 0; for (int i = 0; i < n; i++) { if (!used[i]) {...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int H[101] = {0}; int n, x; cin >> n; for (int i = 0; i < n; i++) cin >> x, H[x]++; int ats = 0; int box = 0; while (box <= 100) { if (H[box] == 0) { box++; continue; } ats++; H[box]--; ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class Main { private static Buffered...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int n; int x[110]; multiset<int, greater<int> > s; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &x[i]); sort(x, x + n); for (int i = 0; i < n; i++) { auto y = s.lower_bound(x[i]); if (y == s.end()) { s.insert(1); } else { ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n = int(input()) val = [[]] for x in sorted(int(x) for x in input().split()): for l in val: if x >= len(l): l.append(x) break if len(val[-1]) > 0: val.append([]) print(len(val) - 1)
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class T389C { public void solve(int n, int[] x) { Arrays.sort(x); int cur = 0; int ans...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
//https://codeforces.com/problemset/problem/388/A //A. Fox and Box Accumulation import java.util.*; import java.io.*; public class CF_388_A{ public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new Out...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 111; int n, ans; int a[maxn]; bool v[maxn]; void Init() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); } void Work() { sort(a + 1, a + 1 + n); while (1) { int pos = 1; while (v[pos] && pos <= n) pos++; if (pos == n +...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 109; int a[N], c[N]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; ++i) scanf("%d", &a[i]); sort(a, a + n); reverse(a, a + n); int ans = -1; for (int i = 1; i <= n; ++i) { memset(c, 0, sizeof(c)); for (int j = 0; j < i; ++j)...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.util.*; public class c228 { public static void main(String ar[]) { Scanner obj=new Scanner(System.in); int n=obj.nextInt(); int a[]=new int[n]; boolean b[]=new boolean[n]; Arrays.fill(b,false); for(int i=0;i<n;i++) a[i]=obj.nextInt(); Arrays.sort(a); int cnt=n; int ret=0; int cur=0; while(cnt>0) { ret+=1; ...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int n, x[105], used[105], ans = 0; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; sort(x, x + n); for (int i = 0; i < n; i++) { if (!used[i]) { used[i] = 1; int l = 1; for (int j = i + 1; j < n; j++) { if (!used[j] && l...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n = int(input()) a = sorted(map(int, input().split()), reverse=True) def ok(cnt): stacks = [[] for _ in range(cnt)] for i, val in enumerate(a): stacks[i % cnt].append(val) for stack in stacks: for i, val in enumerate(stack): if val < len(stack) - i - 1: return Fa...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int arr[101]; int main() { int i, j, n, ans = 0, size = 0; scanf("%d", &n); int b[n]; for (i = 0; i < n; i++) { scanf("%d", &b[i]); arr[b[i]]++; } for (i = 0; i <= 100; i++) { size = 0; if (arr[i] > 0) { ans++; arr[i]--; size++;...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.IOException; import java.util.Arrays; import java.io.OutputStream; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Mahmoud Aladdin <aladdin3> */ public class Main { public static void main(String[] args) { InputSt...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.util.Scanner; import java.io.OutputStream; import java.io.IOException; import java.util.Arrays; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Himalay(himalayjoriwal@gmail.com) */ public class Main { public static ...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n = int(input()) x = sorted(list(map(int, input().split()))) a = [0] * n ans = 0 for i in range(n): ok = False for j in range(ans): if x[i] >= a[j]: a[j] += 1 ok = True break if ok == False: ans+=1 a[ans - 1] = 1 print(ans) ...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n,ans = input(),0 a = map(int,raw_input().split()) h = [(len(filter(lambda x:x <= i,a))+i)/(i+1) for i in range(101)] print max(h)
PYTHON
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int n; int a[110], d[110]; void solve() { int i, j, ans, con, dem; memset(d, 0, sizeof(d)); sort(a, a + n); ans = 0; con = n; while (con) { dem = 0; for (i = 0; i < n; i++) if (d[i] == 0 && a[i] >= dem) { d[i] = 1; dem++; co...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, ans = 0; cin >> n; vector<int> a(n), c(n, 1), p(n, -1); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); while (a.size()) { fill(c.begin(), c.begin() + a.size(), 1); fill(p.begin()...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-9; const int inf = (1 << 30) - 1; const long long inf64 = ((long long)1 << 62) - 1; const long double pi = 3.1415926535897932384626433832795; template <class T> T sqr(T x) { return x * x; } template <class T> T abs(T x) { return x < 0 ? -x : x...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class A { public static void main(String[] args) throws Exception{ int n = readInt(); int[] t = new int[n]; for(int i = 0; i < n; i++){ t[i] = readInt(); } Arrays.sort(t); ...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.Scanner; public class round389problemc { static Scanner in = new Scanner(System.in); public static void main(String[] args) { int n=in.nextInt(); ArrayList<Integer> a=new ArrayList<Integer>(); for(int i=0;i...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.*; import java.util.*; public class CodeForces { public void solve() throws IOException { int n = nextInt(); List<Integer> arr = new ArrayList<Integer>(); int res = 0; for (int i = 0; i < n; i++) { arr.add(nextInt()); } Collections.sort(arr); while (arr.size() > 0) { int h = 0; ...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int i, j, k, n, ans, used; int main() { cin >> n; int a[n]; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); while (used < n) { ans++; k = 0; for (i = 0; i < n; i++) if (a[i] >= k) { a[i] = -1; k++; used++; } }...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n=int(raw_input()) l=map(int,raw_input().split()) ans=chk=cnt=0 l.sort() while n: if n==chk: chk=0 cnt=0 if cnt==0: ans+=1 l.pop(0) cnt+=1 n-=1 elif cnt<=l[chk]: l.pop(chk) cnt+=1 n-=1 else: chk+=1 print ans
PYTHON
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
def correct(a): n = len(a) for i in range(n): for j in range(len(a[i])): if (a[i][j] < len(a[i]) - j - 1): return False return True n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) ans = n for i in range(n, 0, -1): cur = [] for j in rang...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.util.Scanner; import java.util.TreeMap; public class C228 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] w = new int[101]; for(int i = 0; i < n; i++) w[s.nextInt()]++; int ans = 0; int cov = 0; int r = 100; int l = 0; int t = 0;...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long n, i, j, x = 0, ans = 0, term = 0; long a[101]; bool vis[101] = {}; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); while (x < n) { ans++, term = 0; for (i = 0; i < n; i++) if (...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
N = input() a = map(int, raw_input().split()) a.sort() p = [1] for x in a[1:]: mini = min(p) if x >= mini: p[p.index(mini)] += 1 else: p.append(1) print len(p)
PYTHON
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n = int(input()) ip = input().split(' ') ip2 = sorted(list(map(int, ip))) count = 0 keys = set(ip2) while len(ip2) != 0: stack = [] for x in keys: while (len(stack)<= x and ip2.count(x) > 0): stack.append(x) del[ip2[ip2.index(x)]] count = count + 1 print(count) ...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.PriorityQueue; import java.util.StringTokenizer; import java.util.TreeMap; public class C { static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); stati...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int N; int C[101]; int main() { cin >> N; for (int i = 0; i < N; i++) { int x; cin >> x; C[x]++; } int k = 0; while (true) { bool f = false; int c = -1; for (int x = 100; x >= 0; x--) { if (C[x] > 0) { C[x]--; c = x; ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 4000009; int main() { int n; cin >> n; int a[111]; int x, ans = 0; int xep[111] = {0}; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++) { x = 0; if (!xep[i]) { x++; ans...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int n, a[200]; int dp[200]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); dp[0] = 1; for (int i = 1; i < n; i++) { int ma = -1, v = -1; for (int j = 0; j < i; j++) if (dp[j] <= a[i] && dp[j] > ma) ma = dp[j], v = j; ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.*; import java.math.BigInteger; import java.util.*; import java.text.*; public class cf389c { static BufferedReader br; static Scanner sc; static PrintWriter out; public static void initA() { try { br = new BufferedReader(new InputStreamReader(System.in)); ...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> x; int ans = 0; for (int i = 0; i < n; i++) { int t; cin >> t; x.push_back(t); } sort(x.begin(), x.end()); while (!x.empty()) { for (int i = 0; i <= n; i++) { if (lower_bound(x.begin(), x.end(),...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.util.*; public class BruteForce{ public static Scanner in=new Scanner(System.in); public static void main(String[]args){ int n=in.nextInt(); int[]z=new int[n]; for(int i=0;i<n;i++) z[i]=in.nextInt(); Arrays.sort(z); int count=0; int given...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n=int(input()) l=[int(i) for i in input().split()] l.sort() piles=[] for x in l: if x==0: piles.append(1) continue f=0 for i in range(len(piles)): if piles[i]<=x: piles[i]+=1 f=1 break if not f: piles.append(1) print(len(piles))
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
from sys import maxint raw_input() box_caps = map(int, raw_input().split(' ')) box_caps.sort(key=lambda x: -x) stacks = [] while len(box_caps) != 0: current_cap = box_caps.pop() # Select for the current element a stack that it can hold with the lowest surplus capacity selected_stack = None min_surplus = maxin...
PYTHON
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
/***** BY MURAD ******/ /*Everyone has a different way of thinking, so God Created us*/ /*Hope You Respect My Way..,Thank You*/ import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; Out...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
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.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; import...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } sort(v.rbegin(), v.rend()); int ans = n; for (int i = 1; i < n; i++) { vector<vector<int> > piles(i); for (int j = 0; j < n; j++) piles[j % i].push_back(...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.util.*; import java.io.*; //DONT FORGET TO CHANGE CLASS NAME! public class FoxBox { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); StringTokenizer st=new StringTokenizer(sc.nextLine()); int numBoxes=Integer.parseInt(st.nextToken(...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int n; int x[107]; bool cmpr(int a, int b) { return a > b; } int main() { cin >> n; for (int i = 0; i < n; ++i) cin >> x[i]; sort(x, x + n, cmpr); for (int ans = 1; ans <= n; ++ans) { bool ok = true; for (int i = 0; i < ans && ok; ++i) { for (int j = i...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.*; import java.util.*; public class cf { static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner(Reader in) { br = new BufferedReader(in); } public FastScanner() { this(new InputStreamReade...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; vector<long long> vec(n); for (int i = 0; i < n; i++) cin >> vec[i]; sort(vec.begin(), vec.end()); vector<long long> vis(n, 0); long long tot = 0, ans = 0; while (tot < n) { ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
def solve(a): a.sort() res = 0 n = len(a) while n > 0: r = [] for i, x in enumerate(a): if x == -1: continue if x >= len(r): r.append(x) n -= 1 a[i] = -1 res += 1 return res n = int(raw_input()) x = map(int, raw_input().split()) print solve(x)
PYTHON
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int i, j, k, x, y, z, m, n, ans, p, q, r; int ara[400]; int main() { cin >> n; for (i = 0; i < n; i++) cin >> ara[i]; sort(ara, ara + n); ans = 0; for (i = 0; i < n; i++) { if (ara[i] == -1) continue; x = ara[i]; ara[i] = -1; for (j = i + 1, x = 1;...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1e2 + 10; int dp[maxn]; int n; int a[maxn]; int mp[maxn]; int mo[maxn]; int v(int u) { int res = 0; for (int i = u; i < maxn; i++) { res += mo[i]; } return res; } void of(int k, int f) { for (int i = k; i < maxn && f > 0; i++) { if (mo[i] ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] data = new int[n]; ...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; long long a[n]; for (long long int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); vector<long long int> v; v.push_back(0); for (long long int i = 0; i < n; i++) { long long j = 0; while (1) { if (j == (lon...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5, mod = 1e9 + 7; multiset<int> q, v; int n, a[maxn], cnt, ans; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); int cur = 1; while (cur <= n) { ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
# coding: utf-8 n = int(input()) ans = 0 li1 = [int(i) for i in input().split()] li2 = [] while li1: li1.sort() n = len(li1) i = 0 while i < n: if li1[i] < i: li2.append(li1[i]) del(li1[i]) n -= 1 else: i += 1 ans += 1 li1 = li2 ...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int a[101]; bool b[101]; int main() { int n, i, j, nrb, rasp = 0; cin >> n; for (i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); for (i = 1; i <= n; i++) if (b[i] == 0) { nrb = 1; b[i] = 1; j = i + 1; while (j <= n) { f...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.util.Scanner; public class C { public static void main(String args[]){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int a[] = new int[500]; for(int i=0;i<n;i++){ int b = in.nextInt(); a[b]++; } ...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 111; int a[maxn]; int b[maxn]; int main() { int n; while (~scanf("%d", &n)) { memset(b, 0, sizeof(b)); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); b[a[i]]++; } sort(a, a + n); int x = a[n - 1]; int t = n; in...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
n=input() a=map(int,raw_input().split()) a.sort() p=[0]*n c=0 for i in a: for j in range(n): if p[j]<=i: p[j]+=1 c=max(c,j) break print c+1
PYTHON
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; int a[101]; int used[101]; int p = 0; int main() { int n; scanf("%d", &n); int i, j; for (i = 1; i <= n; i++) { scanf("%d", &a[i]); } sort(a + 1, a + 1 + n); for (i = 1; i <= n; i++) { if (used[i] == 0) { int t = 1; p++; used[i] = 1; ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
//package codeforces; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class FoxandBoxAccumulation { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int N = in.nextIn...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; long long n, m, a[2000], s, k, l, i, j, b[2000], p; int main() { cin >> n; for (i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + 1 + n); while (p == 0) { p = 1; l = 0; for (i = 1; i <= n; i++) if (l <= a[i] && b[i] == 0) { l++; b[i]...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; inline int init() { int now = 0, ju = 1; char c; bool flag = false; while (1) { c = getchar(); if (c == '-') ju = -1; else if (c >= '0' && c <= '9') { now = now * 10 + c - '0'; flag = true; } else if (flag) return now * ju; ...
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int test = 1; while (test--) { solve(); } return 0; } void solve() { int n; cin >> n; multiset<int> st; for (int i = 0; i < n; i++) { int x; cin >> x; st....
CPP
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
num = int(input()) boxes = list(map(int, input().split())) boxes.sort(reverse=True) piles = [] while boxes: box = boxes.pop() for pile in piles: if box >= len(pile): pile.append(box) break else: piles.append([box]) print(len(piles)) # 1536683664960
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
from sys import stdin inFile = stdin tokens = [] tokens_next = 0 def next_str(): global tokens, tokens_next while tokens_next >= len(tokens): tokens = inFile.readline().split() tokens_next = 0 tokens_next += 1 return tokens[tokens_next - 1] def nextInt(): return int(next_str()) de...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
input() X=sorted(map(int,raw_input().split())) r=0 while X: r+=1;X=X[1:];t=0 while 1: l=[i for i in X if i>t] if[]==l:break X.remove(l[0]);t+=1 print r
PYTHON
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.*; import java.util.*; public class FoxAndBoxAccumulation { public static void main(String[] args){ int n = ni(); int[] a = na(n); Arrays.sort(a); int i, group = 0, count; for(i=0; i<n; i++){ if(a[i]!=-1){ group++; count = 1; for(int j=i+1; j<n; j++){ if(a[j]!=-1){ ...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.*; import java.util.*; public class problem389C { public static void main (String[]args)throws IOException{ BufferedReader x = new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(x.readLine()); StringTokenizer st=new StringTokenizer(x.readLine()); int[]values=new int[n]...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.*; import java.util.*; public class FoxAndBoxAccumulation { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); StringBuilder out = new StringBuilder(); int n, ind, t; int[] boxes; ArrayList<LinkedList<Integer>>...
JAVA
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import sys import collections case = int(sys.stdin.readline()); test = sys.stdin.readline().split(" "); num = [int(x) for x in test] stats = collections.defaultdict(int); for i in num: stats[i]+=1; key = sorted(stats) total = 0; while sum(stats.values())>0: stack = []; for i in key: if(stats[i]>0...
PYTHON3
389_C. Fox and Box Accumulation
Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For exampl...
2
9
import java.io.InputStreamReader; import java.io.IOException; import java.util.Arrays; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public cla...
JAVA