prompt
string
response
string
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int str[2000000]; bool can[2000000]; int main() { int i, j, k; int n, m, d; int now; while (cin >> n >> d) { for (i = 1; i <= n; i++) { scanf("%d", &str[i]); } sort(str + 1, str + 1 + n); now = 0; memset(can, false, sizeof(can)); can[0]...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> int dp[51 * 10001]; int main(void) { int n, d, a, sum, i, j; while (scanf("%d%d", &n, &d) != EOF) { sum = 0; memset(dp, 0, sizeof(dp)); dp[0] = 1; for (i = 0; i < n; i++) { scanf("%d", &a); sum += a; for (j = sum; j >= a; j--) { if (dp[j - a] == 1) ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int a[500003]; vector<int> p; int main() { int N, D, u; cin >> N >> D; for (int i = 0; i < 500003; ++i) { a[i] = 0; } a[0] = 1; p.push_back(0); for (int i = 0; i < N; ++i) { cin >> u; for (int j = p.size(); j--;) { if (p[j] + u < 500003 && !a...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; bitset<500005> dp; int N, D, ans, i, j, x, d, s = 1; int main() { dp[0] = 1; for (scanf("%d%d", &N, &D), i = 0; i < N; i++) { scanf("%d", &x); for (j = 500000; j >= x; j--) dp[j] = (dp[j] || dp[j - x]); } while (s) { for (s = 0, i = min(ans + D, 500000);...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const int N = 55; const int D = 10100; int dp[N * D]; int n, d; int A[N]; void do_package() { memset(dp, 0, sizeof(dp)); dp[0] = 1; for (int i = 0; i < n; i++) { for (int j = N * D - 1; j >= 0; j--) { if (dp[j] && j + A[i] < N * D) { dp[j + A[i]] = 1...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int dp[550001], c[10005]; int main() { int n, d; cin >> n >> d; for (register int i = 1; i <= n; i++) { cin >> c[i]; } memset(dp, 0, sizeof(dp)); dp[0] = 1; for (register int i = 1; i <= n; i++) { for (register int j = 550000; j >= c[i]; j--) { i...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int dp[5000100]; int main() { int i, j, n, d; int cnt = 0, sum = 0, c = 0; dp[0] = 1; cin >> n >> d; int p; for (i = 0; i < n; i++) { cin >> p; for (j = (sum += p); j >= p; j--) if (dp[j - p] == 1) dp[j] = 1; } while (1) { j = d + c; wh...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const unsigned long long P = 239017, MaxN = 2100000, INF = 1000000000; int n, d, can[510100], a[1000]; vector<int> q; int main() { scanf("%d%d", &n, &d); for (int i = 0; i < n; ++i) scanf("%d", &a[i]); can[0] = 1; for (int i = 0; i < n; ++i) { for (int have = 50...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const int MAXN = 500010; bool vis[MAXN] = {0}; int M[MAXN]; int N, K, T; int main() { cin >> N >> K; vis[0] = true; for (int i = 1; i <= N; i++) { cin >> T; for (int j = i * 10000; j >= 0; j--) if (vis[j]) vis[j + T] = true; } int all = 0; for (int...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const int sz = 112345; int a[100]; bool dp[52][500005]; int sums[500005]; int main() { int n, d, i, j, ans, day; scanf("%d", &n); scanf("%d", &d); for (i = 0; i < n; i++) { scanf("%d", &a[i]); } for (i = 0; i < 500005; i++) dp[0][i] = 0; dp[0][0] = 1; fo...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int dp[555555]; int a[55]; int n, k; int main() { memset(dp, 0, sizeof(dp)); cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; dp[0] = 1; for (int i = 0; i < n; i++) for (int j = 555555; j >= a[i]; j--) dp[j] |= dp[j - a[i]]; int ans = 0, day = 0; wh...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed; cout.precision(12); solve(); return 0; } template <typename T> void sc(T& x) { cin >> x; } template <typename Head, typename... Tail> void sc(Head& head, Tail&... tail) { cin ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; vector<int> arr; int n, d; int have; int lastHave; int dp[50][10000 * 55]; bool knapsack() { for (int j = lastHave + 1; j <= have + d; ++j) dp[0][j] = (arr[0] <= j) ? arr[0] : 0; for (int i = 1; i < n; ++i) { for (int j = lastHave + 1; j <= have + d; ++j) { ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int arr[50 + 5]; bool Sum[(int)1e4 * 50 + 5]; int main() { int N, D, ans = 0, maxi = 0, tot = 0; scanf("%d %d", &N, &D); for (int i = 0; i < N; i++) { scanf("%d", &arr[i]); tot += arr[i]; } Sum[0] = 1; for (int i = 0; i < N; i++) for (int j = tot - a...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int N, D; int val[60]; int dp[10010 * 60]; int main() { int i, j; cin >> N >> D; int sum = 0; dp[0] = 1; for (i = 0; i < N; i++) { cin >> val[i]; sum += val[i]; for (j = sum; j >= val[i]; j--) { if (dp[j - val[i]]) { dp[j] = 1; } ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e6; int a[maxn], dp[maxn]; int main() { int n, d; scanf("%d%d", &n, &d); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); dp[0] = 1; for (int i = 1; i <= n; i++) for (int j = 600000; j >= a[i]; j--) dp[j] = max(dp[j], dp[j - a[i]]); int ans...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:268435456,268435456") using namespace std; int a[50]; bool dp[510001]; int main() { int n, d; scanf("%d %d", &n, &d), dp[0] = 1; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); for (int j = 510001 - 1; j >= a[i]; j--) dp[j] |= dp[j - a[i]]; } ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const int N = 555555; bool dp[N]; int main() { int n, d; while (cin >> n >> d) { memset(dp, 0, sizeof(dp)); int c; dp[0] = 1; for (int i = 0; i < n; i++) { cin >> c; for (int j = N - 1; j >= c; j--) dp[j] |= dp[j - c]; } int mx = 0, c...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const long long A = 100000000000000LL, N = 2228228; long long dp[N], i, j, n, r, m, a, o[2]; int main() { cin >> n >> m, dp[0] = 1; for (i = 0; i < n; i++) { cin >> a, r += a; for (j = r; j >= a; j--) if (dp[j - a]) dp[j] = 1; } while (1) { j = o[0...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
import java.util.*; public class b { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(), d = input.nextInt(); boolean[] possible = new boolean[1000000]; possible[0] = true; int[] data = new int[n]; for(int i = 0; i<n; i++) data[i] = input.nex...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int a[300], b[500001], m, n, d; bool used[51][500001], used1[500001]; void solve(int i, int s) { used1[s] = true; if (i > n) return; if (used[i][s]) return; used[i][s] = true; solve(i + 1, s); solve(i + 1, s + a[i]); } int main() { cin >> n >> d; for (int i ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const int MAX_BUF_SIZE = 16384; char BUFOR[MAX_BUF_SIZE]; int BUF_SIZE, BUF_POS; char ZZZ; int _MINUS; const int MXN = 2000010; const int C = 262144; const int INF = 1000000001; const int MXS = 500010; bool knapsack[MXN]; int n, d; int c[MXN]; priority_queue<pair<int, int> ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const int maxn = 511111; int num[maxn]; int q[maxn]; int main() { int i, j, n, m, k; scanf("%d%d", &n, &m); memset(num, 0, sizeof(num)); num[0] = 1; for (i = 1; i <= n; i++) { scanf("%d", &k); for (j = 500000; j >= k; j--) { if (num[j - k]) num[j] = ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const int MN = 50; const int MVAL = 500000; const int MM = 505050; bool can[MM]; int main() { int n, d; scanf("%d %d", &n, &d); can[0] = true; int i, j; for ((i) = 0; (i) < (int)(n); ++(i)) { int a; scanf("%d", &a); for (j = MVAL; j >= 0; --j) { ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> int n, m, d; bool dp[55 * 10100]; int main() { dp[0] = true; scanf("%d %d", &n, &d); for (int i = 0; i < n; ++i) { int t; scanf("%d", &t); for (int j = m; j >= 0; --j) if (dp[j]) dp[j + t] = true; m += t; } int cur = 0, days = 0; bool changed = true; while (c...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const int maxn = 55, maxv = 500005; int n, D, a[maxn], f[maxv], b[maxv], now, cnt; int main() { scanf("%d%d", &n, &D); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); f[0] = 1; for (int i = 1; i <= n; i++) for (int j = 500000; j >= a[i]; j--) f[j] |= f[j - a[i]...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const int maxix = 60; const int maxnum = 1000 * 1000 * 1000 + 10; const int maxd = 50 * 10000 + 10000; int dp[maxd], mark[maxd]; int arr[maxix]; int main() { int n, d; cin >> n >> d; for (int i = 1; i <= n; i++) { cin >> arr[i]; } sort(arr + 1, arr + n + 1); ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const int M = 500000 + 10; int a[M]; int dp[2][M]; vector<int> x; int main() { int n, d; cin >> n >> d; for (int i = 1; i <= n; i++) { cin >> a[i]; } dp[0][0] = 1; for (int i = 1; i <= n; i++) { int flag = i % 2; int pre = 1 - flag; for (int j = ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int p[50 * 10000 + 1]; int v[50]; int solve_problem() { vector<int> positions; int n, d; if (scanf("%d %d", &n, &d) != 2) return 1; for (int i = 0; i < n; i++) if (scanf("%d", &v[i]) != 1) return 1; int s = 0; for (int i = 0; i < n; i++) s += v[i]; sort(v,...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed; cout.precision(12); solve(); return 0; } template <typename T> void sc(T& x) { cin >> x; } template <typename Head, typename... Tail> void sc(Head& head, Tail&... tail) { cin ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int dp[500001]; int main() { int n, d, x = 0, i, j; int a[50]; scanf("%d %d", &n, &d); for (i = 0; i < n; i++) scanf("%d", &a[i]); dp[0] = 1; for (i = 0; i < n; i++) { for (j = 500000; j >= 0; j--) { if (dp[j] == 1) dp[j + a[i]] = 1; } } for (i...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int n, d, a[55], f[500005][55], s[1000005]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cin >> n >> d; for (int i = 1; i <= n; i++) { cin >> a[i]; } fill(f[0], f[0] + n + 2, 1); vector<int> v(1); for (int i = 1; i < 500005; i++) { for (...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; stringstream ss; long long mod = 1000000007LL; int a[64], dp[500010]; int main() { int n, d; cin >> n >> d; dp[0] = 1; for (int i = 0; i < n; i++) { cin >> a[i]; for (int j = 500000; j >= a[i]; j--) if (dp[j - a[i]]) dp[j] = 1; } vector<int> cand; ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const double EPS = 0.0000001; const double PI = acos(-1); const long long INFLL = 0x7FFFFFFFFFFFFFFF; const int INF = 0x7FFFFFFF; template <typename T> inline void next(T &num) { char c; num = 0; do { c = getchar_unlocked(); } while (c != EOF && c == ' ' && c ==...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int main() { set<int> s; s.insert(0); int n, d; cin >> n >> d; 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++) { set<int> temp; for (set<int>::iterator it = s.begin(); it != s...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int q[505050], f[505050], g[505050], a[505050]; int main() { int n, D; scanf("%d%d", &n, &D); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); int m = 0; for (int i = 1; i <= n; i++) m += a[i]; memset(g, 0, sizeof(g)); g[0] = 1; for (int i = 1; i <= n; i++) ...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; bool used[50]; int n; int ss[500001], v[50]; int main(void) { int d; int i, ans = 0, sum = 0, j; scanf("%d%d", &n, &d); for (i = 0; i < n; i++) { scanf("%d", &v[i]); sum += v[i]; } ss[0] = true; for (i = 0; i < n; i++) for (j = sum; j >= v[i]; j--)...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:268435456,268435456") using namespace std; bool dp[510001]; int main() { int n, d, t; scanf("%d %d", &n, &d), dp[0] = 1; for (int i = 0; i < n; i++) { scanf("%d", &t); for (int j = 510000; j - t >= 0; j--) dp[j] |= dp[j - t]; } int curr = 0, num...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; const int MAXN = 10000 * 55; const long long LINF = 1000000000LL * 1000000000LL; bool f[MAXN], fn[MAXN]; long long ff[MAXN]; int i, j, n, w, d, a[111]; map<long long, int> x; int main() { cin >> n >> d; for (i = 0; i < n; i++) { cin >> a[i]; w += a[i]; } f[0...
Problem: John Doe has recently found a "Free Market" in his city β€” that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note...
#include <bits/stdc++.h> using namespace std; int n, d, a[60], t; bool best[500100]; vector<int> s; int main() { cin >> n >> d; for (int i = 1; i <= n; ++i) { cin >> a[i]; t += a[i]; } best[0] = 1; for (int i = 1; i <= n; ++i) for (int j = t - a[i]; j >= 0; --j) { best[j + a[i]] = max(best[j...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long INF = 1e18; int main() { double n, i, k, m = 101; cin >> n; vector<long long> a(n, 0); vector<double> b(101, 0); for (i = 0; i < (n); i++) { cin >> a[i]; b[a[i]]++; } double x = 0, y = 0; for (i = 0; ...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; long long i, j, k, l, n, a, b, ans = 0; int main() { std::ios_base::sync_with_stdio(0); cin >> n; vector<long long> num(n); for (i = 0; i < n; i++) { cin >> num[i]; } sort(num.begin(), num.end()); for (i = 0; i < n; i++) { if (num[i] == -1) continue; ...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long a; cin >> a; vector<long long> x; for (long long i = 0; i < a; i++) { long long b; cin >> b; x.push_back(b); } bool done[101] = {false}; sort(x.begin(), x...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> v(n); for (long long int i = 0; i < n; i++) cin >> v[i]; sort(v.begin(), v.end()); int ans = 0; while (!v.empty()) { ans++; int num = 0; for (lon...
Problem: 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. F...
import sys inp = [map(int, i.split(' ')) for i in sys.stdin.read().strip().splitlines()] dat = sorted(inp[1]) res = 0 while dat: chain = 0 for i in xrange(len(dat)): if dat[i] >= chain: chain += 1 dat[i] = -1 res += 1 dat = filter(lambda x: x >= 0, dat) sys.stdout.wri...
Problem: 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. F...
#------------------------template--------------------------# import os import sys from math import * from collections import * from fractions import * from bisect import * from heapq import* from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') BUF...
Problem: 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. F...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class CSolver { private static InputReader in; private static PrintWriter out; public static void main(String[] args) thro...
Problem: 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. F...
import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; import java.io.InputStream; import java.io.InputStreamReader; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static ...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; bool v[110]; int cnt[110]; vector<int> a; int main() { int test; int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; if (v[x] == false) { v[x] = true; } a.push_back(x); cnt[x]++; } int l = a.size(); vector<int> v1; s...
Problem: 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. F...
input();print(max([((ind+1)//(i+1)+((ind+1)%(i+1)!=0)) for ind,i in enumerate(sorted(map(int,input().split())))]))
Problem: 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. F...
import java.util.*;import java.io.*;import java.math.*; public class Main { public static void process()throws IOException { int n=ni(); int[]A=nai(n); Arrays.sort(A); int ans=1; for(int i=1;i<n;i++) if(A[i]<(i/ans)) ans++; pn(ans); ...
Problem: 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. F...
import java.io.FileReader; import java.io.IOException; import java.math.BigInteger; import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class CodeForces { class pairT implements Comparable<pairT>{ int count; ...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; bool used[110]; int main() { int n, a[110], ans = 0; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); while (true) { int i; for (i = 0; i < n; i++) if (!used[i]) break; if (i == n) break; ans++; int h = 0; for (i = 0...
Problem: 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. F...
import java.io.*; import java.util.*; import java.math.*; public class Main { static BufferedReader in; static PrintWriter out; static StringTokenizer tok; static void solve() throws Exception { int n = nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = nextInt(); } Arrays.sort...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int a[105], b[105]; bool cmp(int x, int y) { return x > y; } int main() { int t, i, n, j; cin >> n; for (i = 1; i <= n; i++) { scanf("%d", &a[i]); } sort(a + 1, a + 1 + n, cmp); for (t = 1;; t++) { memset(b, -1, sizeof(b)); bool flag = 0; for (i ...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int n; int a[101]; int b[101]; vector<int> x; int res; void Init() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; b[a[i]]++; } } void AB() { for (int i = 0; i <= 100; i++) { while (b[i] > 0 && i >= x.size()) { x.push_back(i); b[i]--; ...
Problem: 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. F...
n = raw_input() n = int(n) boxes = raw_input() boxes = boxes.split() boxes = map(int, boxes) piles = [] while len(boxes) > 0: pile = [] s = max(boxes) boxes.remove(s) if s != 0: temp_boxes = boxes while len(temp_boxes) > 0 and len(pile)<s: smallest = min(temp_boxes) ...
Problem: 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. F...
''' Created on 01-Jul-2017 @author: kandarp ''' import sys def check(x,a): if x ==0 : return False; b =[] ans = True; for i in xrange(0,x): b.append([]); for i in xrange(0,len(a)): b[i%x].append(a[i]) for i in xrange(0,x): for j in xrange(0,len(b[i])): ...
Problem: 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. F...
import java.util.Arrays; import java.util.Scanner; public class FoxAndBox { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] x = new int[n]; for(int i=0; i<n; i++){ x[i] = sc.nextInt(); } ...
Problem: 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. F...
n=int(input()) li=list(map(int,input().split(" ",n)[:n])) li.sort() ans=1 for i in range(n): if li[i]< i//ans: ans+=1 print(ans)
Problem: 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. F...
import java.util.Scanner; import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; Outpu...
Problem: 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. F...
import java.util.*; public class cf388A { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int boxes = sc.nextInt(); int[] strengths = new int[101]; for(int i = 0; i < boxes; i++) { strengths[sc.nextInt()]++; } int[] piles =...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int main() { int n, count = 0; int arr[200]; cin >> n; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); vector<int> ans; int k = 0; int l; ans.push_back(1); for (int i = 1; i < n; i++) { if (arr[i] == 0) ans.push_back(1); else...
Problem: 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. F...
import math from decimal import * getcontext().prec=30 n=int(input()) x=list(map(int,input().split())) x.sort() l=list() for i in range(len(x)): added=0 for j in range(len(l)): if x[i]>=len(l[j]): l[j].append(x[i]) added=1 break if not added: v=[x[i]] ...
Problem: 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. F...
#include <bits/stdc++.h> int b[110], vis[110]; int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; } int main(void) { int n, i, cur, k, pile; while (scanf("%d%*c", &n) != EOF) { for (i = 0; i < n; i++) scanf("%d", &b[i]); qsort(b, n, 4, cmp); memset(vis, 0, sizeof(vis)); k = 0; ...
Problem: 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. F...
import java.util.*; import java.io.*; //DONT FORGET TO CHANGE CLASS NAME! public class FoxAndBoxAccumulation { /* First, we need to put all of our box strengths into an array. We can then sort the array from least to greatest Finally, we have a linked list to keep track of the number of boxes in each p...
Problem: 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. F...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public final class FoxBox { /** * @param args */ public static void main(String[] args) { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); try ...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<pair<long long, pair<long long, long long> > > v; for (long long i = 1; i <= n; i++) { long long x; cin >> x; v.push_back(make_pair(x, make_pair(1, x))); } sort(v.begin(), v.end()); while (1) { bool pa...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int n, t, ans; multiset<pair<int, int> > S; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> t; S.insert(make_pair(t, 1)); } while (!S.empty()) { bool F = false; pair<int, int> cur = *S.begin(); S.erase(S.begin()); for (multiset<pa...
Problem: 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. F...
from collections import defaultdict def partition(seq, key=int): d = defaultdict(int) for x in seq: d[key(x)] += 1 return d def popBox(boxes, x): if boxes[x] == 1: del boxes[x] else: boxes[x] -= 1 nBoxes = int(raw_input()) boxes = partition([x for x in raw_input().split()]...
Problem: 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. F...
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Stack; import java.util.StringTokenizer; import static java.util.Arrays.sort; public class FoxAndBox...
Problem: 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. F...
n = int(raw_input()) X = map(int, raw_input().split()) L = [[] for i in xrange(100)] X.sort() for i in xrange(n): x = X[i] for j in xrange(n): if len(L[j]) <= x: L[j] += [x] break print sum([L[i] != [] for i in xrange(n)])
Problem: 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. F...
def Acc(arr): arr.sort() arr_aux=[0 for i in range(len(arr))] i=0 j=0 while i<len(arr): if arr[i]>=arr_aux[j]: arr_aux[j]=arr_aux[j]+1 i+=1 j=0 else: j+=1 #print(arr_aux) valor_actual=len(arr)-arr_aux.count(0) print(valor_ac...
Problem: 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. F...
n = int(input()) l = list(map(int,input().split(' '))) l.sort() nb = 0 for i in range(n): if l[i] == -1 : continue h = 1 nb += 1 for j in range(i+1,n): if l[j]>=h: h+=1 l[j] = -1 print(nb)
Problem: 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. F...
"""Template for Python Competitive Programmers prepared by Mayank Chaudhary aka chaudhary_19""" # to use the print and division function of Python3 from __future__ import division, print_function """value of mod""" MOD = 10 ** 9 + 7 """use resource""" # import resource # resource.setrlimit(resource.RLIMIT_STACK, [0x...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; int main() { auto start = high_resolution_clock::now(); ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; ++i) cin >> v[i]; sort(v.begin(), v.end()); priority_queue<in...
Problem: 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. F...
#include <bits/stdc++.h> int main() { int sayac = 0, x, n, t1, t = 0, i, j, arr[105] = {0}; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &x); arr[x]++; } while (1) { t = 0; t1 = 1; for (i = 0; i <= 100; i++) if (arr[i]) t1 = 0; if (t1) break; for (i = 0; i <= 100; i...
Problem: 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. F...
n=input() h=[0] p=sorted(map(int,raw_input().split())) for x in p: if x<min(h): h+=[1] else: h[h.index(min(h))]+=1 print len(h)
Problem: 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. F...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java....
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int main() { int n; std::cin >> n; int arr[n]; for (int i = 0; i < n; i++) { std::cin >> arr[i]; } sort(arr, arr + n); vector<int> vis(n, 0); int ans = 0, total = n; while (total) { int cnt = 0; for (int i = 0; i < n; i++) { if (!vis[i] &...
Problem: 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. F...
#from collections import deque n = map(int,input().split()) x = sorted(list(map(int,input().split()))) piles = 1 current = x.pop(0) current_size = 1 while x: for i,e in enumerate(x): if e >= current_size: current = e x.pop(i) current_size += 1 break else:...
Problem: 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. F...
import java.util.*; public class FoxAndBox { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = Integer.parseInt(s.nextLine()); List<Integer> boxes = new ArrayList<>(n); for (int i = 0; i < n; i++) { boxes.add(s.nextInt()); } Collections.sort(boxes); int count = 0; ...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int arr[1000], ans = 0; int cnt[1000]; int main() { int n; scanf("%d", &n); priority_queue<int> pq; for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); pq.push(-x); } for (int i = 0; i < 1000; ++i) { arr[i] = 0; cnt[i] = 0; } while (!pq...
Problem: 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. F...
import java.util.Arrays; import java.util.Scanner; public class Main { public static boolean check(int[] arr, int no){ int[] piles = new int[no]; for(int i = 0; i < arr.length; i++){ boolean isPossible = false; for(int j = 0; j < no; j++){ if(piles[j] <= arr[i]){ piles[j]++; isPossible = tru...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int n, pile, cnt, ans = 0; multiset<int> s; multiset<int>::iterator it; int main(void) { ios ::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i <= n; ++i) { cin >> pile; s.insert(pile); } while (s.size()) { s.erase(s.begin()); cnt = 1;...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; const long long int inf = 1e18; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); vector<long long int> arr[100]; long long int n, t, i, p, j, cnt = 0; cin >> n; long long int v[n]; for (i = 0; i < n; i++) cin >> v[i]; sort(v, ...
Problem: 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. F...
#include <bits/stdc++.h> const int inf = (int)1e9; const int mod = 1e9 + 7; using namespace std; int a[111], ans = 0; bool cmp(int x, int y) { return (x > y); } bool u[111]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1...
Problem: 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. F...
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Scanner; import java.uti...
Problem: 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. F...
import java.io.InputStreamReader; import java.io.IOException; import java.io.*; import java.io.OutputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; import java.util.Arrays; import java.util.Collections; import java.io.InputStream; public class Main...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); vector<int> v; vector<int> st; vector<vector<int> > vv; for (int i = 0; i < n; i++) { int x; scanf("%d", &x); v.push_back(x); } sort(v.rbegin(), v.rend()); for (int i = 0; i < n; i++) { int x = v[i]; ...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int n; vector<int> inp; vector<vector<int> > dip; void input() { cin >> n; inp.resize(n); for (int i = 0; i < n; ++i) cin >> inp[i]; } void owp() { dip.resize(1); dip[0].push_back(inp[0]); for (int i = 1; i < n; ++i) { int q = dip.size(); bool b = true; ...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int a[101]; bool vis[101] = {0}; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); int ans = 0, tot = n; sort(a + 1, a + n + 1); while (tot) { int cnt = 0; for (int i = 1; i <= n; i++) { if (!vis[i] && cnt <= a[i...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v; int num; for (int i = 0; i < n; i++) { cin >> num; v.push_back(num); } sort(v.begin(), v.end()); int cnt = 0; int all = 0; vector<bool> taken(v.size(), false); while (true) { int cur = 0; for...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, ans = 0, ps, j, f; cin >> n; int a[n], b[n], pile[n + 1]; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i <= n; i++) { pile[i] = 0; } sort(a, a + n); ans = 1; pile[ans]++; for (i = 1; i < n; i++) { f = 0; f...
Problem: 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. F...
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; @SuppressWarnings("unchecked") public class P388A { public void run() throws Exception { TreeMap<Integer, Integer> xc = new TreeMap(); for (int n = nextInt(); n > 0; n--) { int x = nextInt(); xc.put(x, xc.getOrD...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b) { long long int ans; while (b > 0) { if (b % 2 == 1) { ans *= a; } b /= 2; a *= a; } return ans; } struct comparator { bool operator()(long long int i, long long int j) { return i > j; } }...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; int c[n]; for (int i = 0; i < n; i++) { cin >> a[i]; c[i] = 0; } sort(a, a + n); int w = 0; ; for (int i = 0; i < n; i++) { if (c[i] == 0) { int x = c[i]; int e = 1; w++; c[i] = ...
Problem: 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. F...
n = int(input()) a = list(map(int, input().split())) a.sort() uni = {} for elem in a: if elem not in uni: uni[elem]=1 else: uni[elem]+=1 piles = [] while len(a)>0: box = a.pop(0) if len(piles)==0: piles.append([box]) else: for i in range(len(piles)): temp...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int N; vector<int> V; bool solve(int n); int main() { ios_base::sync_with_stdio(false); int i, st, dr, mid; cin >> N; V.resize(N); for (i = 0; i < N; ++i) { cin >> V[i]; } sort(V.begin(), V.end()); st = 1; dr = N; while (st < dr) { mid = (st + dr...
Problem: 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. F...
#include <bits/stdc++.h> using namespace std; int n; int a[101], b[101]; int ans[101]; int main() { int i, j; while (cin >> n) { memset(b, 0, sizeof(b)); for (i = 0; i < n; i++) cin >> a[i], b[a[i]]++; memset(ans, 0, sizeof(ans)); int now = 0, Max = 0; for (i = 0; i <= 100; i++) { if (b[i]...