output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; int n; int a[100001]; int cnt[1000001]; int lt[1000001]; int rt[1000001]; int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d", a + i); ++cnt[a[i]]; rt[a[i]] = i; } for (int i = n - 1; i > -1; --i) { lt[a[i]] = i; } int mx = -1;...
### Prompt In cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> int n = 0, m = 0, a[100002], b[1000002], c[1000002]; int main() { while (scanf("%d", &n) != EOF) { memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); if (n == 0) continue; int max = 0; int p = 0, q = 0, k = 0; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); ...
### Prompt Generate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const int maxn = 100005; int cnt[maxn * 10]; int l[maxn * 10], r[maxn * 10]; int main() { int n; scanf("%d", &n); int a; memset(l, -1, sizeof(l)); memset(r, -1, sizeof(r)); for (int i = 0; i < n; i++) { scanf("%d", &a); cnt[a]++;...
### Prompt Generate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; pair<int, int> A[(int)1e6 + 10]; int b[(int)1e6 + 10]; int main() { int n; cin >> n; int t; for (int i = 0; i < n; i++) { cin >> t; b[t]++; if (A[t].first == 0) A[t].first = i + 1; A[t].second = i + 1; } int mx = -1; for (int i = 0; i < 1e6 + 1...
### Prompt Your task is to create a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; struct num { int count; int start; int end; } N[1000001]; bool compare(const struct num &f, const struct num &s) { if (f.count != s.count) return f.count > s.count; else return (f.end - f.start) < (s.end - s.start); } int main() { int n, i; cin >> n; ...
### Prompt Please create a solution in cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int n; map<int, int> cc, start, endd; int main() { ios_base::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) { int x; cin >> x; cc[x]++; start[x] = !start[x] ? i : min(start[x], i); endd[x] = !endd[x] ? i : max(endd[x], i); } int cur...
### Prompt Generate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; const int N = 1000005; const long long mod = (1e9) + 7; int n; int cnt[N], a[N]; vector<int> vec[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); cin >> n; for (int i = 1; i <= n; i++) { int x; ci...
### Prompt Develop a solution in Cpp to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int n; int A[100010]; int has[1000100]; int l[1000100]; int r[1000100]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> A[i]; has[A[i]]++; if (!l[A[i]]) l[A[i]] = i; r[A[i]] = i; } int mx = 0; for (int i = 1; i <= 1000000; i++) mx = ma...
### Prompt Develop a solution in Cpp to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; const int M = 1000000007; const int N = 100010; const int K = 1000010; int n, x[N], mx; vector<int> v[K]; int main() { ios::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; ++i) { cin >> x[i]; v[x[i]].push_back(i); mx = max(mx, int(v[x[i]].size())); ...
### Prompt Please create a solution in CPP to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); static int freq[1000001]; static int l[1000001]; static int r[1000001]; int arr; for (register int i = 0; i < n; i++) { scanf("%d", &arr); if (l[arr] == 0) { l[arr] = i + 1; r[arr] = i + 1; freq[ar...
### Prompt In CPP, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; int main() { int mxc = 0; map<int, int> m; map<int, int>::iterator it; map<int, pair<int, int> > p; int n; cin >> n; int nn; int minInd = 1000009; int mnc = 1000009; for (int i = 1; i <= n; i++) { cin >> nn; it = m.find(nn); if (it != m.end()...
### Prompt In cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; int firstOccur[1000010]; int secondOccur[1000010]; int cnt[1000010]; int main() { int i, j, k, n, v1; scanf("%d", &n); int mx = 0; for (i = 0; i < n; i++) { scanf("%d", &v1); if (firstOccur[v1] == 0) firstOccur[v1] = i + 1; secondOccur[v1] = i + 1; c...
### Prompt Please provide a CPP coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; long long qp(long long a, long long b, long long mod) { long long t = 1; while (b) { if (b & 1) t = t * a % mod; b >>= 1; a = a * a % mod; } return t; } struct DOT { int x; int y; }; inline void read(int &x) { int k = 0; char f = 1; char c = ge...
### Prompt Please provide a Cpp coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; struct node { int tot; int l, r; }; map<int, node> mm; inline int getInt() { char ch = getchar(); while (ch > '9' || ch < '0') ch = getchar(); int num = 0; while (ch <= '9' && ch >= '0') { num = num * 10 + (ch - '0'); ch = getchar(); } return num; } ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; class UnionFind { private: vector<int> p, rank; public: UnionFind(int N) { rank.assign(N, 0); p.assign(N, 0); for (int i = 0; i < N; i++) { p[i] = i; } } int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); } bool isSameSe...
### Prompt Generate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; template <class T1> void debug(T1 e) { cout << e << endl; } template <class T1, class T2> void debug(T1 e1, T2 e2) { cout << e1 << "\t" << e2 << endl; } template <class T1, class T2, class T3> void debug(T1 e1, T2 e2, T3 e3) { cout << e1 << "\t" << e2 << "\t" << e3 <<...
### Prompt Your challenge is to write a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; int b[maxn]; map<int, vector<int> > a; int main() { int n, x; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &x); b[i] = x; if (!a.count(x)) { a[x] = vector<int>(); } a[x].push_back(i + 1); } sort...
### Prompt Please create a solution in CPP to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; struct node { int s; int e; int num; } b[1000005]; int a[1000005]; int main() { int n; int i; while (scanf("%d", &n) != EOF) { for (i = 1; i < 1000005; i++) { b[i].num = 0; b[i].s = -1; b[i].e = -1; } for (i = 1; i <= n; i++) { ...
### Prompt In Cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { if (!b) return a; return gcd(b, a % b); } template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); } long long modpow(long long a, long long b, long long mod) { long long x = 1, y = a; while (b > 0) { if (b % 2 ...
### Prompt Please formulate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; const int N = 1000005; struct pi { int num, l, r; } c[N]; int n, u; int main() { while (scanf("%d", &n) != EOF) { memset(c, 0, sizeof(c)); for (int i = 1; i <= n; i++) { scanf("%d", &u); if (c[u].num == 0) c[u].l = i; c[u].num++; c[u].r =...
### Prompt In cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; const int inf = 1000 * 2000 * 1000, MOD = 1000 * 1000 * 1000 + 7; const long long INF = 1000 * 1LL * 1000000 * 1000 * 1000000; vector<int> cnt[1001000], need; int a[200000], n; int main() { srand(time(NULL)); scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("...
### Prompt Please create a solution in cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int l[N], r[N], cnt[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); for (int i = 0; i < N; ++i) { l[i] = 1e9; r[i] = -1e9; } int n; std::cin >> n; int mx = 0; for (int i = 0; i < n; ++i) { int x; std::cin...
### Prompt Your task is to create a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; const int NMAX = 1e5 + 5; const int MAX = 1e6 + 5; int n; int a[MAX]; int l[MAX], r[MAX], sum[MAX]; int main() { fill(l, l + MAX, 1e9); fill(r, r + MAX, -1); cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; sum[a[i]]++; l[a[i]] = min(l[a[i]], i); ...
### Prompt Generate a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; const int MAXNUM = 1000010; int A[MAXNUM]; int B[MAXNUM]; void __main() { int n; cin >> n; fill(A, A + MAXNUM, 0); for (int i = 0; i < n; i++) { int temp; cin >> temp; A[temp]++; B[i] = temp; } int maxoc = *max_element(A, A + MAXNUM); map<int, ...
### Prompt Develop a solution in cpp to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; const int N = 1000005; struct pi { int num, l, r; } c[N]; int n, u; int main() { while (scanf("%d", &n) != EOF) { memset(c, 0, sizeof(c)); for (int i = 1; i <= n; i++) { scanf("%d", &u); if (c[u].num == 0) c[u].l = i; c[u].num++; c[u].r =...
### Prompt Your challenge is to write a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> template <typename T> std::istream& operator>>(std::istream& input, std::vector<T>& v) { for (T& a : v) input >> a; return input; } void answer(size_t x, size_t y) { std::cout << 1 + x << ' ' << 1 + y << '\n'; } void solve(const std::vector<unsigned>& a) { const size_t n = a.size(); str...
### Prompt Create a solution in Cpp for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> const double PI = 3.141592653589793238460; using namespace std; long long pows(long long a, long long n, long long m) { long long res = 1; while (n) { if (n % 2 != 0) { res = (res * a) % m; n--; } else { a = (a * a) % m; n = n / 2; } } return res % m;...
### Prompt Your task is to create a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; pair<int, int> a[N]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i].first), a[i].second = i; sort(a, a + n); int l = 0, mx = 0, L = 0, R = 0; for (int i = 1; i < n; i++) { if (a[i].first != a[i - 1]....
### Prompt Your challenge is to write a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; int a[100005]; int cnt[1000005]; int beg[1000005]; int een[1000005]; int main() { int n, maxx = 1; memset(cnt, 0, sizeof(cnt)); scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); if (cnt[a[i]] == 0) beg[a[i]] = i; cnt[a[i]]++; een[a[...
### Prompt Generate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; int n; int st[1001000], en[1001000], num[1001000]; int l, r; int tim; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { int x; scanf("%d", &x); ++num[x]; if (!st[x]) st[x] = i; en[x] = i; } for (int x = 1; x < 1001000; ++x) { if (n...
### Prompt In Cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int numbers[100000]; map<int, int> r; map<int, int> l; map<int, int> cnt; for (int i = 0; i < n; i++) { cin >> numbers[i]; if (l[numbers[i]] == 0) { l[numbers[i]] = i + 1; r[numbers[i]] = i + 1; cnt[numbe...
### Prompt Create a solution in Cpp for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; map<long long, long long> m, lo, hi; int main() { long long total, val; cin >> total; long long save; long long max1 = -1; for (long long i = 1; i <= total; i++) { cin >> val; m[val]++; if (!lo[val]) lo[val] = i; hi[val] = i; if (m[val] > max1)...
### Prompt In Cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; struct count_a { int v, min, max; count_a() { v = 0; min = 0; max = 0; } }; count_a cnt[1000005]; int num[100005]; int main() { int n; int max_num = 0, last_value = 0, last_dis = 100005; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d...
### Prompt Create a solution in Cpp for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; const int32_t MOD = 1000000007; long long int prime[1000001] = {0}, ans = 0; long long int pwe(long long int a, long long int b) { if (b == 0) return 1; long long int res = pwe(a, b / 2); res *= res; res %= MOD; if (b % 2) return (res * a) % MOD; else re...
### Prompt Please provide a CPP coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; int a[100005], c[1000005], L[1000005], R[1000005]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); if (c[a[i]] == 0) L[a[i]] = i; R[a[i]] = i; c[a[i]]++; } int ma = -1, ans = 1; for (int i = 1; i <= 1000000...
### Prompt Your task is to create a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int arr[100002]; bool vis[1000002]; int b[1000002], e[1000002]; vector<int> v1; vector<pair<int, int> > v2; bool compare(pair<int, int> p1, pair<int, int> p2) { if ((p2.second - p2.first) > (p1.second - p1.first)) return true; return false; } int main(...
### Prompt Your task is to create a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; const int mod = 1e9 + 7; void solve() { int n; cin >> n; vector<int> a(n), cnt(maxn, 0), left(maxn, 0), right(maxn); for (int i = 0; i < n; i++) { cin >> a[i]; cnt[a[i]]++; if (left[a[i]] == 0) left[a[i]] = i + 1; right[a[i]...
### Prompt Please formulate a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, i, x; map<long long, int> mp; long long a[100005]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%I64d", &a[i]); mp[a[i]]++; } map<long long, int>::iterator it; int maxi = -1; fo...
### Prompt In Cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-6; const int INF = (int)(INT_MAX - 100); const long long mod = (int)(1e+9 + 7); const int N = (int)(1e6); int main() { int n; cin >> n; vector<int> v(n), k(N + 1), d(N + 1); vector<pair<int, int> > e(N + 1, {n, 1}); for (int i = 0; i < n...
### Prompt Please formulate a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, z = 0, d = 1e7, p, k; map<long long int, long long int> m; cin >> n; long long int a[n + 1]; vector<pair<long long int, long long int> > v; v.push_back(make_pair(0, 0)); for (i = 1; i <= 1000000; i++) v.push_back(make_pair(0, 0...
### Prompt Please provide a CPP coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; template <class T> using v2d = vector<vector<T> >; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } mt19937 rng(chrono::system_clock::now().time_since_epoch(...
### Prompt Please provide a cpp coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; int l[2000000 + 10], r[2000000 + 10], t[2000000 + 10], n; int main() { int ma = 0, ans = 2139062143, j = 0, i; for (i = 1; i <= 1000000; i++) l[i] = 2139062143, r[i] = -2139062143, t[i] = 0; cin >> n; for (i = 1; i <= n; i++) { int p; scanf("%d", &p); ...
### Prompt Generate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; const int maxn = 1000005; int freq[maxn], start[maxn]; int main() { int n, d, bestFreq = 0, bestSeg = maxn, l, r; scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &d); if (freq[d] == 0) start[d] = i; ++freq[d]; if (freq[d] > bestFreq) { ...
### Prompt Please provide a Cpp coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; const int N = 100005; struct pi { int a, x; } c[N]; bool cmp(pi a, pi b) { if (a.a != b.a) return a.a < b.a; return a.x < b.x; } int n, pre, num, ans; int nl, nr, l, r; void fun() { if (num < pre) { num = pre; l = nl; r = nr; ans = r - l + 1; } els...
### Prompt Construct a CPP code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; int main() { int n; int x; cin >> n; int maxocc = 0; int dis = numeric_limits<int>::max(); unordered_map<int, int> occ; unordered_map<int, int> start; int candl = 1; int candr = 1; for (int i = 0; i < n; i++) { cin >> x; if (occ.count(x) == 0) { ...
### Prompt Please create a solution in CPP to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, max = 0, len, s; cin >> n; map<int, int> m; map<int, int> l; for (int i = 0; i < n; ++i) { int temp; cin >> temp; if (m[temp]) m[temp]++; else { m[temp]++; l[temp] = i; } if (m[temp] > max) { m...
### Prompt Develop a solution in cpp to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int _left[1000009]; int cnt[1000009]; int main() { int l, r; int n, x; cin >> n; int _min = 0; int _max = 0; for (int i = 0; i < n; i++) { cin >> x; if (!cnt[x]) { _left[x] = i; } cnt[x]++; if (_max < cnt[x]) { _max = cnt[x]; ...
### Prompt Please provide a cpp coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; long long F[1000007], L[1000007]; long long C[1000007]; int main() { for (long long i = (0); i < (1000007); i++) { F[i] = -1; L[i] = -1; } memset(C, 0, sizeof(C)); long long n; scanf("%lld", &n); for (long long i = (0); i < (n); i++) { long long v; ...
### Prompt Please provide a CPP coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; map<int, int> mp; set<int> st; set<int>::iterator it; int main() { int x, mx = 0; cin >> x; int y[x]; vector<vector<int> > buff(999999); for (int i = 0; i < x; i++) { cin >> y[i]; mp[y[i]]++; if (mp[y[i]] > mx) { mx = mp[y[i]]; } } for (i...
### Prompt Please create a solution in Cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> int main() { int numbers; while (scanf("%d", &numbers) == 1) { int data[numbers + 1]; int *first_occur = (int *)calloc(1000001, sizeof(int)); int *last_occur = (int *)calloc(1000001, sizeof(int)); int *count = (int *)calloc(1000001, sizeof(int)); int max = 0; for (in...
### Prompt Construct a cpp code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; struct arr { int s, e; long long int ti = 0; } ar; map<int, arr> v; queue<int> q; int main() { int n; while (cin >> n) { int mt = -1; for (int i = 1; i <= n; i++) { int r; cin >> r; if (v[r].ti == 0) v[r].s = i; v[r].ti++; v[r]....
### Prompt Please create a solution in CPP to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int arr[1000005], s[1000005], e[10000005]; int main() { int i, j, n; memset(arr, 0, sizeof(arr)); memset(s, -1, sizeof(s)); memset(e, -1, sizeof(e)); cin >> n; int max = -1, maxi, l = INT_MAX; for (i = 1; i < n + 1; i++) { cin >> j; arr[j]++; if (s...
### Prompt Please create a solution in cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); vector<int> v(n, 0); unordered_map<int, int> m; for (int i = 0; i < n; i++) { scanf("%d", &v[i]); if (m.find(v[i]) != m.end()) { m[v[i]]++; } else m[v[i]] = 1; } int mx = -1; unordered_set<int> nos...
### Prompt Please formulate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; long long int v[4005]; long long int d[4005]; long long int p[4005]; long long int arr[100005]; pair<pair<int, int>, int> hasher[1000006]; int main() { int n, maxi = -1, num, ansl, ansr; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; hasher[arr[i]].sec...
### Prompt Generate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; int n, m; int mark[1000005]; int a[1000005]; int c[1000005][2]; int main() { scanf("%d", &n); memset(c, 0, sizeof(c)); memset(mark, 0, sizeof(mark)); int maxx = 0, z = 0; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); if (z < a[i]) z = a[i]; mark[a...
### Prompt Develop a solution in cpp to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int MaxOcc; const int inf = 1 << 30; int AnswerProblem = inf; int AnswerLeft, AnswerRight; int cnt[1048576]; int helloworld1[1048576], helloworld2[1048576]; int main() { int n, i; cin >> n; for (i = 0; i < n; i++) { int a; cin >> a; if (!cnt[a]) helloworld...
### Prompt Create a solution in cpp for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; long long int v[4005]; long long int d[4005]; long long int p[4005]; long long int arr[100005]; pair<pair<int, int>, int> hasher[1000006]; int main() { int n, maxi = -1, num, ansl, ansr; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; hasher[arr[i]].sec...
### Prompt Develop a solution in cpp to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; const double pi = 2 * acos(0.0); const double eps = 1e-9; const int MOD = (int)1e9 + 7; long long pow(long long base, long long exp, long long mod) { long long result = 1; while (exp > 0) { if (exp & 1) result *= base; base *= base; if (base > mod) base %= m...
### Prompt Please formulate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; pair<int, pair<int, int> > mx[1000001]; int main() { ios::sync_with_stdio(false); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int x; for (int i = 0; i < n; i++) { cin >> x; mx[x].first++; if (!mx[x].second.fi...
### Prompt Please formulate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; struct beauty { int t; int l, r; beauty() : t(0) {} }; const int maxn = 1e6 + 7; const int N = 1e5 + 7; int arr[N]; beauty cnt[maxn]; int main() { cin.tie(0); cin.sync_with_stdio(0); int n, v; while (cin >> n) { int maxt = 0; memset(arr, 0, sizeof(arr)...
### Prompt Your challenge is to write a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const double pi = acos(-1.0); int n, a[100011], d[1000111], l[1000111], r[1000111]; int main() { cin >> n; int m = 0, k = -1; memset(l, -1, sizeof l); memset(r, -1, sizeof r); for (int i = 0; i < n; ++i) { cin >> a[i]; d[a[i]]++; ...
### Prompt Construct a cpp code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv) { int n, a; cin >> n; map<int, pair<int, pair<int, int>>> x; int c[100001]; for (int i = 0; i < n; i++) { cin >> a; c[i] = a; x[a].second.first = 10000000; } for (int i = 0; i < n; i++) { x[c[i]].first++; x[c...
### Prompt Construct a Cpp code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; int n; int st[1001000], en[1001000], num[1001000]; int l, r; int tim; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { int x; scanf("%d", &x); ++num[x]; if (!st[x]) st[x] = i; en[x] = i; } for (int x = 1; x < 1001000; ++x) { if (n...
### Prompt Construct a CPP code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; long long i, j, k, z1, c, n, t, a[1000005], q, p1, l, r, x, y, pi[1000005], nu, ex, re, ii, ans, ma = -1000, t1; map<long long, long long> mp, mp1; int main() { cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; mp[a[i]]++; if (mp1[a[i]] == 0) mp1[a[i]] =...
### Prompt Please formulate a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; struct node { int v, pos; } a[100010]; bool cmp(node x, node y) { if (x.v == y.v) return x.pos < y.pos; return x.v < y.v; } int main() { int n, x; while (~scanf("%d", &n)) { for (int i = 1; i <= n; i++) { scanf("%d", &a[i].v); a[i].pos = i; } ...
### Prompt Develop a solution in CPP to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int a[100005], c[1000005], poz[1000005]; int main() { int n, i, j, k, p, q, x, y, mn, mx, l, r; while (scanf("%d", &n) == 1) { memset(c, 0, sizeof c); memset(poz, 0, sizeof poz); x = -1; for (i = 1; i <= n; i++) { scanf("%d", &a[i]); c[a[i]]+...
### Prompt Please create a solution in Cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int mx = -1; map<int, vector<int>> pos; for (int i = 0; i < n; i++) { int x; cin >> x; pos[x].push_back(i); mx = max(mx, (int)pos[x].size()); } int mn = n + 1; ...
### Prompt Please provide a CPP coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long tt = 1; while (tt--) { int n; int i, j; cin >> n; vector<pair<int, pair<int, int> > > a(1000001); for (i = 0; i < 1000001; i++) { a[i].first = 0; a[i].second.firs...
### Prompt Please create a solution in Cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int a[200005]; int cnt[1000005]; int minloc[1000005]; int maxloc[1000005]; int main() { int i, n; cin >> n; int mcnt = 0; memset(minloc, 7, sizeof(minloc)); for (i = 0; i < n; i++) { cin >> a[i]; cnt[a[i]]++; mcnt = max(cnt[a[i]], mcnt); minloc[a[i...
### Prompt Please formulate a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; map<int, pair<int, pair<int, int> > > m; int main() { int n; scanf("%d", &n); int maxx = -1; for (int i = 0; i < n; i++) { int x = 0; scanf("%d", &x); if (m[x].first == 0) { m[x].first = 1; m[x].second.first = i + 1; m[x].second.second ...
### Prompt Your challenge is to write a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; long long n, i, t[1000005], a[1000005][2], x, mi, ma, le; int main() { ios::sync_with_stdio(false); cin >> n; for (i = 1; i <= n; i++) { cin >> x; t[x]++; if (t[x] == 1) { a[x][0] = i; } a[x][1] = i; } x = 0; mi = 0; ma = 1000005; f...
### Prompt Your challenge is to write a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; const int maxn = 1100000; int msq[maxn]; int Msq[maxn]; int MSq[maxn]; int MSQ[maxn]; int MSQQ[maxn]; int n; int main() { while (scanf("%d", &n) != EOF) { memset(Msq, 0, sizeof(Msq)); memset(MSQ, 0, sizeof(MSQ)); for (int i = 0; i < n; i++) { scanf("%d",...
### Prompt Your task is to create a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; int a[100000], b[100000]; int main() { int n; cin >> n; map<int, int> map1; map<int, int> map2; map<int, bool> mapbool; int res[200000] = {0}; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; if (!mapbool[a[i]]) { mapbool[a[i]] = true;...
### Prompt Create a solution in Cpp for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; int a[1000100][3]; int main() { int n; cin >> n; for (int i = 0; i < 1000010; i++) a[i][0] = 0; int r; int max_length = 0; int nomer = 0; int length = 1000000; for (int i = 0; i < n; i++) { cin >> r; if (a[r][0] == 0) { a[r][0] = 1; a[r][...
### Prompt Your challenge is to write a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; int n; int tra; int maxl; int l; int r; int ans = (int)1e9; struct NUM { int sta; int end; int timel; } num[1000001]; bool comp(const NUM &a, const NUM &b) { return a.timel > b.timel; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &...
### Prompt Construct a cpp code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 100; vector<int> a, f(1e6 + 100); vector<int> v[N]; int main() { int n; cin >> n; a.resize(n); int mx = -1; for (int i = 0; i < n; i++) { cin >> a[i]; f[a[i]]++; v[a[i]].push_back(i); mx = max(mx, f[a[i]]); } for (int i = 0;...
### Prompt In Cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; int n, a[100010], b[1000010], l[1000010], r[1000010], ans; void work() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]), b[a[i]]++; if (!l[a[i]]) l[a[i]] = i; r[a[i]] = max(r[a[i]], i); } for (int i = 1; i <= 1e6; i++) if ((b[ans]...
### Prompt In cpp, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> int freq[1000005], l[1000005], r[1000005]; int main() { int n, x; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &x); if (freq[x]++ == 0) { l[x] = i; } r[x] = i; } int a = -1, b, c; for (int i = 0; i < 1000005; i++) { if (freq[i] > a) { a...
### Prompt Please provide a cpp coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; struct amr { int s; int l; int c; }; amr s[1000005]; int main() { ios_base::sync_with_stdio(false); int n, x; cin >> n; for (int i = 0; i < n; i++) { cin >> x; if (s[x].c == 0) s[x].s = i; s[x].c++; s[x].l = i; } int maxx = 0, loc = -1; f...
### Prompt Construct a cpp code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; int be[1000001], en[1000001], nu[1000001]; int main() { int n, i, a, l = 0, r = 0, o = 0; cin >> n; for (i = 1; i <= n; i++) { cin >> a; if (be[a] == 0) { be[a] = i; en[a] = i; nu[a] = 1; } else { en[a] = i; nu[a]++; } }...
### Prompt In CPP, your task is to solve the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some num...
#include <bits/stdc++.h> using namespace std; struct Cut { int val; int kol; int l, r; Cut(int val = 0, int kol = 0, int l = 0, int r = 0) { this->val = val; this->kol = kol; this->l = l; this->r = r; } bool operator<(const Cut &c) const { return kol > c.kol || kol == c.kol && (r - l) < ...
### Prompt Your challenge is to write a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; const int inf = 0x7FFFFFFF; struct point_int { int x, y; point_int() {} point_int(int a, int b) { x = a, y = b; } }; struct point_double { double x, y; point_double() {} point_double(double a, double b) { x = a, y = b; } }; struct Node { int v, w; Node() {} ...
### Prompt Please provide a cpp coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; int a[1000010]; int ll[1000010]; int rr[1000010]; int main() { int n; cin >> n; int max = 0; for (int i = 0; i < n; ++i) { int q; cin >> q; if (a[q] == 0) ll[q] = i; rr[q] = i; ++a[q]; if (a[q] > a[max]) { max = q; } } int l = 0...
### Prompt Please create a solution in Cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int main() { int n, mx = -100000, mn = 1000000000, x, i, lu; cin >> n; vector<int> cnt(1e6 + 5), l(1e6 + 5); for (i = 0; cin >> x; i++) { if (cnt[x] == 0) l[x] = i; cnt[x]++; if (mx < cnt[x]) mx = cnt[x], lu = l[x], mn = i - lu; else if (mx == ...
### Prompt Please formulate a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 6; struct mang { int sl = 0, dau = 0, cuoi = 0; } a[maxn], ans; int n, x, y, z; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> x; ++a[x].sl; if (a[x].sl =...
### Prompt Please provide a cpp coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve() { int n; cin >> n; vector<int> v(n); unordered_map<int, int> count; set<int> s; int maxc = 0; for (long long i = 0; i < (n); i++) { cin >> v[i]; count[v[i]]++; maxc = max(maxc, count[v[i]]); } for (auto i : v)...
### Prompt Construct a CPP code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; int main(int argc, const char* argv[]) { ios_base::sync_with_stdio(false); int count; cin >> count; map<int, pair<int, pair<int, int> > > data; int t; for (int i = 0; i < count; i++) { cin >> t; if (data.count(t) == 0) { data.insert(make_pair(t, ma...
### Prompt Generate a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; long long n, x; long long p[3][1000009]; long long maxx; long long ans1, ans2, ans3 = 100009; int main() { ios_base::sync_with_stdio(0); cin >> n; for (long long i = (0); i < (n); i++) { cin >> x; p[0][x]++; if (p[0][x] == 1) p[1][x] = i + 1; p[2][x] =...
### Prompt Construct a cpp code solution to the problem outlined: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some n...
#include <bits/stdc++.h> using namespace std; int freq[1000010]; int A[1000010]; bool marked[1000010]; vector<pair<int, int> > v(1000010); int main() { int n; cin >> n; int maxa = 0; for (int i = 0; i < n; i++) { cin >> A[i]; freq[A[i]]++; maxa = max(maxa, freq[A[i]]); } for (int i = 0; i < 1000...
### Prompt Please formulate a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > v; int arr[1000005], li[1000005], ri[1000005]; int main() { int i, j, k, n, m, x, y, arr1[100005], maxi, max1, l, r; cin >> n; memset(arr, 0, sizeof arr); memset(li, 0, sizeof li); memset(ri, 0, sizeof ri); for (i = 0; i < n; i++) { c...
### Prompt Create a solution in Cpp for the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some numb...
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 1, -1, 0}; int dy[] = {1, 0, 0, -1}; long double PI = 3.14159265358979323846264338327950; const int N = 1e6 + 10; int st[N], End[N], mp[N]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[n]; for (int i = 1; i <= n;...
### Prompt Your challenge is to write a cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; const int M = 100005; int a[M]; int has[M * 10 * 2]; int l[M * 10]; int main() { int n; int maxx = -1; int minx = 100 * M; int tmp, tmp2; scanf("%d", &n); int ch = -1; for (int i = 0; i < n; i++) { int x; scanf("%d", &x); if (has[x] == 0) { h...
### Prompt Generate a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int maxi = 0; long mini = n; vector<int> beaty_elem(1000005, 0); vector<int> distance(1000005, 0); int x; int ch = 1; for (int i = 1; i <= n; i++) { cin >> x; if (beaty_elem[x] == 0) { beaty_elem[x] = 1; di...
### Prompt Generate a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; int e[1000000 + 10], s[1000000 + 10], t[1000000 + 10], a[1000000 + 10]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; t[a[i]]++; if (s[a[i]] == 0) s[a[i]] = i; e[a[i]] = i; } int mx = 0, l = 0, r = 0; for (int i = 1; i...
### Prompt Please formulate a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> int b[1000001], d[1000001], c[1000001], a[100000]; int main() { int i, n, ans, num, max; for (i = 0; i <= 1000000; i++) { b[i] = 0; } scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a[i]); b[a[i]]++; if (b[a[i]] == 1) { c[a[i]] = i + 1; } d[a[i]] ...
### Prompt Please provide a cpp coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...
#include <bits/stdc++.h> using namespace std; int mark[1000005], beauty; vector<int> last[1000005]; int n; int a[1000005], l, r; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; last[a[i]].push_back(i); mark[a[i]]++; beauty = max(beauty, mark[a[i]]); } int ans = INT_MAX; for (...
### Prompt Develop a solution in cpp to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int l[1000005], r[1000005], cnt[1000005]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { int x; cin >> x; cnt[x]++; if (l[x] == 0) l[x] = i; r[x] = i; } int ll, rr, mx = -1, dff = 9999999; for (int i = 1; i <= 1000000; i++) { ...
### Prompt Please create a solution in cpp to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that som...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int n; cin >> n; vector<pair<int, pair<int, int> > > has(1000005, {0, {n, -1}}); vector<int> arr(n); int a; int maxc = 0; for (int i = 0; i < n; i++) { cin >> a; arr[i] = a; has[a].first++; maxc = max(max...
### Prompt Generate a CPP solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number...
#include <bits/stdc++.h> using namespace std; int cnt[1000005]; int sp[1000005]; void init(int a[]) { for (int i = 0; i < 1000005; i++) a[i] = 0; } int main() { int n; int max = 0; int dis = 0; while (scanf("%d", &n) != EOF) { int a, r = 0, l = 0; init(cnt); init(sp); for (int i = 0; i < n; i+...
### Prompt Your task is to create a Cpp solution to the following problem: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times th...
#include <bits/stdc++.h> using namespace std; int fst[1000001], last[1000001]; int was[1000001]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int a; cin >> a; if (fst[a] == 0) fst[a] = i + 1; last[a] = i + 1; was[a]++; } int ans = 1e9, ansl = 0, ansr = 0; int maxx = *max_e...
### Prompt Please provide a Cpp coded solution to the problem described below: Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of time...