Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.util.*; import java.lang.Math; public class index { static int biggestOfThree(int x, int y, int z) { if (x >= y && x >= z) // Returning 1st number if largest return x; // Comparing 2nd no with 1st and 3rd no else if (y >= x && y >= z) ...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string numbers[n]; for (int i = 0; i < n; i++) { cin >> numbers[i]; } int max1 = 0; int max2 = 0; int max3 = 0; int result = 55; for (int i = 0; i < n; i++) { if (numbers[i] == "1") max1++; else if (numbers...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int a[1000000]; int max(int x, int y, int z) { int max; if (x >= y) max = x; else max = y; if (z >= max) max = z; return max; } int main() { int n; int m = 0, g = 0, t = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 1)...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int x, u[5], n, Max; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &x), u[x]++, Max = max(u[x], Max); printf("%d", n - Max); return 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, tmp, one = 0, two = 0, three = 0, m; cin >> n; for (int i = 0; i < n; i++) { cin >> tmp; if (tmp == 1) one++; if (tmp == 2) two++; if (tmp == 3) three++; } m = max(one, max(two, three)); cout << n - m; return 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
//package dbarrie.codeforces.beginner; import java.util.Scanner; /* * Codeforces 123 Problem - Difficulty 900 * * https://codeforces.com/problemset/problem/52/A */ public class OneTwoThreeProblem { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] ...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; const int inf = 100000000; const double eps = 0.000001; int main() { int n; cin >> n; vector<int> a(n), res(3, 0); for (int i = 0; i < n; i++) { cin >> a[i]; res[a[i] - 1]++; } cout << res[0] + res[1] + res[2] - max(res[0], max(res[1], res[2])); return...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> int main() { int n, i, c[3] = {0}, x, max; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &x); c[x - 1]++; } max = c[0]; i = 0; if (c[1] > max) { max = c[1]; i = 1; } if (c[2] > max) { max = c[2]; i = 2; } c[i] = 0; printf("%d\n", c[0] + c...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Sequence123 { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLin...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n = input() s = raw_input().split() s1 = s.count('1') s2 = s.count('2') s3 = n - s1 - s2 print n - max(s1,s2,s3)
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int n, x, one, two, three; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> x; if (x == 1) one++; else if (x == 2) two++; else three++; } cout << n - max(one, max(two, three)); }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int n, b; int a[5]; int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> b; a[b]++; } cout << min(min(a[2] + a[3], a[1] + a[2]), a[1] + a[3]); return 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int ar1[1000][1000], ar2[10000000]; int re1 = 0, re2 = 0; int test = 0; int main() { int a = 0, b = 0, c = 0, d = 0, result = 0; scanf("%d", &a); for (int i = 1; i <= a; i++) { scanf("%d", &result); if (result == 1) { b++; } else if (result == 2) { ...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int num[3]; int main() { int n; int tmp; for (int i = 1; i <= 3; i++) num[i] = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &tmp); num[tmp]++; } cout << n - max(num[1], max(num[2], num[3])) << endl; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int n; int a[4]; int main() { ios::sync_with_stdio(false); cin >> n; int t; for (int i = 1; i <= n; i++) cin >> t, a[t]++; cout << min(a[1] + a[2], min(a[2] + a[3], a[3] + a[1])); return 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a1 = 0, a2 = 0, a3 = 0; int num; for (int i = 0; i < n; i++) { cin >> num; if (num == 1) a1++; else if (num == 2) a2++; else a3++; } if (a1 >= a2 && a1 >= a3) cout << a2 + a3; else if (a...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class Test { public BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); public PrintWrit...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n=int(input()) arr=list(map(int,input().split())) s1=arr.count(1) s2=arr.count(2) s3=arr.count(3) print(n-max(s1,s2,s3))
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n = int(raw_input()) lst = map(int, raw_input().split()) one = 0 two = 0 three = 0 for i in range(n): if lst[i] == 1: one += 1 elif lst[i] == 2: two += 1 else: three += 1 a = one + two b = one + three c = two + three lst2 = [] lst2.append(a) lst2.append(b) lst2.append(c) lst2.sort() ...
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; struct wnr { char val; char pos; }; void solve() { long long int n; cin >> n; long long int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } long long int cnt1 = 0; long long int cnt2 = 0; long long int cnt3 = 0; for (int i = 0; i < n; i++) { ...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.util.Scanner; public class Main { public static void main (String [] args) { Scanner input = new Scanner(System.in); String length=input.nextLine(); int numberone=Integer.parseInt(length); int one=0,two=0,three=0; String [] inputtwo=input.nextLine().split(" "); for(int i =0 ; i <numberone;i++) { switch ...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.util.*; public class Main{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int size=sc.nextInt(); int[] arr=new int[3]; for(int i=0;i<size;i++){ int temp=sc.nextInt(); arr[temp-1]++; } int max=0; i...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n=input();a=raw_input();print n-max(a.count(str(i))for i in[1,2,3])
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } int main() { int N; scanf("%d", &N); int cnt[3] = {}; for (int i = 0; i < (int)(N); ++i) { int a; scanf("%d", &a); ++cnt[a - 1]; } cout << (N - *...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long n, one = 0, two = 0, three = 0; scanf("%lld", &n); for (int i = 0; i < n; ++i) { int a; scanf("%d", &a); if (a == 1) { one++; } else if (a == 2) { two++; } else { three++; } } int a = one + two; in...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int a[5]; int n, b; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> b; a[b]++; } sort(a, a + 3 + 1); cout << a[1] + a[2]; return 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n = int(input()) arr = list(map(int,input().split())) h = {} for i in arr: if (i in h): h[i] += 1 else: h[i] = 1 print(n-max(h.values()))
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int n, s[4]; int main() { scanf("%d", &n); for (register int x, i = 1; i <= n; ++i) scanf("%d", &x), ++s[x]; return cout << n - max(s[1], max(s[2], s[3])), 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> const double PI = acos(-1.0); const int MAXN = 1000010; int flg[4], n; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { int x; scanf("%d", &x); flg[x]++; } int max = std::max(flg[1], std::max(flg[2], flg[3])); printf("%d\n", n - max); }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.util.Scanner; import java.util.*; public class Main { static char arr[][]; public static void main(String[] args) { // 19 20 30 Scanner s = new Scanner(System.in); int n = Integer.parseInt(s.nextLine()); int freq[] = new int[4]; String line[] = s.nextLine().split(" "); for (int i=0;i < n...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); int N = in.nextInt(); int[] freq = new int[3]; in.nextLine(); String[] tmp = in.nextLine().split(" "); for (int i=0...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> int main() { int n, s, a = 0, b = 0, c = 0, i, j, k; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &s); if (s == 1) { a++; } else if (s == 2) { b++; } else { c++; } } if (a >= b && a >= c) { j = a; } else if (b >= c && b >= a) { ...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; const long long int maxn = 1e5 + 1; long long int a[maxn], dp[maxn], n, m, d[maxn], z, p; vector<long long> g[maxn]; bool mark[maxn]; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> z; if (z == 1) ...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
numof_input = input() s = raw_input() s = s.split(" ") num1 = 0 num2 = 0 num3 = 0 for i in s: int_i = int(i) if int_i == 1: num1 += 1 if int_i == 2: num2 += 1 if int_i == 3: num3 += 1 re = 0 if num1 >= num2 and num1 >= num3: re = numof_input - num1 if num2 >= num1 and num2 >=...
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
l=lambda:map(int,raw_input().split()) n=input() a=l() d={1:0,2:0,3:0} for x in a: d[x]+=1 print n-max(d.values())
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import sys, math, operator, itertools, collections, heapq, bisect # sys.setrecursionlimit(10**4) class Solution: def __init__(self): pass def solve(self, *Input): cnt = collections.Counter(Input[0]) print(min(cnt[1]+cnt[2],cnt[2]+cnt[3],cnt[3]+cnt[1])) def create(self, *Input): ...
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int a[1000] = {0}, b, c, d, i, j, m; cin >> m; c = 0; for (i = 0; i < m; i++) { cin >> b; a[b]++; if (c < b) { c = b; } } b = 0; d = 0; for (i = 1; i <= c; i++) { b = b + a[i]; if (d < a[i]) { d = a[i]; } ...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
N = int( input() ) A = list( map( int, input().split() ) ) cnt = [ 0 for i in range( 3 + 1 ) ] for i in range( N ): cnt[ A[ i ] ] += 1 print( N - max( cnt ) )
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
a = int(input()) b = list(map(int,input().split())) count1 = 0 count2 = 0 count3 = 0 for i in range(a): if b[i] == 1: count1 +=1 elif b[i] == 2: count2 +=1 else: count3+=1 sum1 = count1+count2 sum2 = count3 + count2 sum3 = count1 +count3 print(min(sum1,sum2,sum3))
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
var n=parseInt(readline()); var a=readline().split(" ").map(e=>+e); var aa = [0, 0, 0, 0]; a.map(e => aa[e]++); aa.sort((a,b)=>b-a); print(n-aa[0]);
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int a[4]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1, tc; long long i, j, k, l, m, n; while (cin >> n) { memset(a, 0, sizeof(a)); for (i = 0; i < n; i++) { cin >> k; a[k]++; } sort(a + 1, a + 4); long long sum ...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int ones = 0, twos = 0, threes = 0; for (int i = 0; i < n; i++) { int temp; cin >> temp; if (temp == 1) ones++; else if (temp == 2) twos++; else threes++; } int mx = max(ones, max(twos, threes))...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n=input() a=raw_input() print n-max(a.count(str(i)) for i in [1,2,3])
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.io.*; import java.util.StringTokenizer; /** * _52A * θ(n) time * θ(1) space * * @author artyom */ public class _52A implements Runnable { private BufferedReader in; private PrintStream out; private StringTokenizer tok; private void solve() throws IOException { int[] bv = new ...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner ; import java.util.StringTokenizer; /** * * @author ahmad97 */ public class Main { /** * @param args the command line arguments */ public static void main...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.util.*; public class Sequence { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n,i,c1=0,c2=0,c3=0,max; int arr[]=new int[1000000]; n=sc.nextInt(); for(i=0;i<n;i++) arr[i]=sc.nextInt(); for(i=0;i<n;i++) { if(arr[i]==1) c1++; else if(arr[i]==2) ...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
/** * Created by ankeet on 7/30/16. */ import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class A52 { static FastReader in = null; static PrintWriter out = null; public static void solve() ...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
from collections import Counter lent = input() lis = list(map(int,raw_input().split())) check = Counter(lis) print(lent - check.most_common(1)[0][1])
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, cou[3] = {0}, a; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a); cou[a - 1]++; } sort(cou, cou + 3); printf("%d\n", n - cou[2]); return 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n = int(input()) x = [int(i) for i in input().split()] counter1 = x.count(1) counter2 = x.count(2) counter3 = x.count(3) ans = counter1 + counter2 if counter3 + counter2 < ans: ans = counter3 + counter2 if counter3 + counter1 < ans: ans = counter3 + counter1 print(ans)
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int a[5]; int main() { int n, x, mx = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &x); a[x]++; } for (int i = 1; i <= 3; i++) { if (a[i] > mx) mx = a[i]; } printf("%d", n - mx); return 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> arr; int p = 0, q = 0, r = 0; for (int i = 0; i < n; i++) { if (a[i] == 1) p++; if (a[i] == 2) q++; if (a[i] == 3) r++; } arr.push_back(p); ...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> int main() { int n, a, r; int c[3] = {}; std::scanf("%d", &n); while (0 < n--) { std::scanf("%d", &a); c[a - 1]++; } r = std::min({c[0] + c[1], c[0] + c[2], c[1] + c[2]}); std::printf("%d\n", r); return 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debu...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n = int(input()) nums = input() a = nums.count("1") b = nums.count("2") c = nums.count("3") d = (a, b, c) e = sorted(d)[0]+sorted(d)[1] print(e)
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
if __name__ == "__main__": n = int(input()) numbers = list(map(int,input().split())) uno = numbers.count(1) dos = numbers.count(2) tres = numbers.count(3) if uno >= dos and uno >= tres: print(dos+tres) elif dos >= uno and dos >= tres: print(uno + tres) elif tres >= dos a...
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
def calculate(list1): ones=0 twos=0 threes=0 for i in list1: if i==1: ones=ones+1 elif i==2: twos= twos+1 else: threes += 1 if (ones>twos and ones> threes): return 1 elif (twos>ones and twos>threes): return 2 elif (...
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { map<int, int> mp; int a, b, mx = 0, cnt = 0, n; vector<int> v; cin >> a; for (int i = 0; i < a; i++) { cin >> b; v.push_back(b); mp[b]++; if (mp[b] > mx) { mx = mp[b]; n = b; } } for (int i = 0; i < a; i++) { if...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n=int(input()) a=[0]*4 for x in list(map(int,input().split())): a[x]+=1 print(min(a[1]+a[2],a[2]+a[3],a[3]+a[1]))
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n = int(input()) a = list(map(int, input().split())) v = [0,0,0] for i in a: if i == 1: v[0] += 1 elif i == 2: v[1] += 1 else: v[2] += 1 print(len(a) - max(v))
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int n, a[10000001]; map<int, int> f; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; ++f[a[i]]; } cout << f[1] + f[2] + f[3] - max(f[1], max(f[2], f[3])); return 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.util.*; import java.io.*; public class Solution { public static void main(String[] args) throws Exception { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int c1 = 0; int c2 = 0; int c3 = 0; for(int i = 0; i < n; i++) { int next = scan.nextInt(); if(next == 1) c1++; i...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; long long b[10005], c, n, l = 0, a, i; int main() { scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a); b[a]++; if (b[a] > c) c = b[a]; } cout << n - c << endl; return 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int n, cnt[3]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { int tmp; scanf("%d", &tmp); cnt[--tmp]++; } int x = cnt[0] + cnt[1]; int y = cnt[1] + cnt[2]; int z = cnt[2] + cnt[0]; printf("%d\n", min(x, min(y, z))); return 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class A123sequence { public static void main(String[] args) { // TODO Auto-generated method stub FastSca...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long n, cnt = 0, ct = 0, c = 0; cin >> n; long long arr[n + 1]; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] == 1) cnt++; else if (arr[i] == 2) ct++; else if (arr[i] == 3) c++; } int ar[3]; ar[0] =...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n = int(input()) a = list(map(int, input().split())) x = 0 y = 0 z = 0 for j in a: if j == 1: x += 1 elif j == 2: y += 1 else: z += 1 a.clear() a.append(x) a.append(y) a.append(z) i = n - max(a) print(i)
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
//package main; import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int elm[] = { 0, 0, 0 }; int t, n = cin.nextInt(); for(int i = 0; i < n; ++i) { t = cin.nextInt(); ++elm[t-...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int size, c, i, count1 = 0, count2 = 0, count3 = 0; scanf("%d", &size); for (i = 0; i < size; i++) { scanf("%d", &c); if (c == 1) count1++; else if (c == 2) count2++; else if (c == 3) count3++; } printf("%d", size - m...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
# http://codeforces.com/problemset/problem/52/A n = int(input()) vals = input().split(' ') counts = sorted([vals.count(str(x)) for x in range(1, 4)], reverse=True) print(counts[1] + counts[2])
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n = int(raw_input().strip()) a = [int(a) for a in raw_input().strip().split(' ')] c1 = a.count(1) c2 = a.count(2) c3 = a.count(3) print min([c1+c2, c1+c3, c2+c3])
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n = input() l = raw_input() c1 = l.count('1') c2 = l.count('2') c3 = n-c1-c2 print n-max(c1, c2, c3)
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n = int(input()) a = list(map(int, input().split())) one = n-a.count(1) two = n-a.count(2) th = n-a.count(3) print(min(one, two, th))
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import collections a = input() s = collections.Counter(map(int,raw_input().split())) print a - max(s.values())
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
num = int(input()) arr = input().split() arr = [int(x) for x in arr] n1 = arr.count(1) n2 = arr.count(2) n3 = arr.count(3) max_recurance = max(n1, n2, n3) print(n1 + n2 + n3 - max_recurance)
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static int p (int n, String s){ int coun1 = 0 ; int coun2 = 0 ; int coun3 = 0 ; s =s.replaceAll(" ", ""); for (int i = 0 ; i < n ; i++){ if (s...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
# -*- coding: UTF-8 -*- # from itertools import * # from collections import defaultdict # def gcd(a,b): # while b > 0: a,b = b, a%b # return a # def baseN(num,b,numerals="0123456789abcdefghijklmnopqrstuvwxyz"): # return ((num == 0) and "0" ) or ( baseN(num // b, b).lstrip("0") + numerals[num % b]) T = ...
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; long long Set(long long N, long long pos) { return N = N | (1 << pos); } long long reset(long long N, long long pos) { return N = N & ~(1 << pos); } bool check(long long N, long long pos) { return (bool)(N & (1 << pos)); } void CI(long long &_x) { scanf("%d", &_x); } void C...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n=int(raw_input()) l=[int(x) for x in raw_input().split()] print n-max(l.count(1),l.count(2),l.count(3))
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int size, c, i, count1 = 0, count2 = 0, count3 = 0; cin >> size; for (i = 0; i < size; i++) { cin >> c; if (c == 1) count1++; else if (c == 2) count2++; else if (c == 3) count3++; } cout << size - max(max(count1, coun...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class Cp { public static void main(String[] args) throws IOException { Sc...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, a, t, i, b[4] = {0}; cin >> n; for (i = 0; i < n; i++) { cin >> a; if (a == 1) b[0]++; else if (a == 2) b[1]++; else if (a == 3) b[2]++; } sort(b, b + 3); cout << b[0] + b[1]; return 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long int n; cin >> n; if (n == 1) { cout << "0"; } else { std::vector<int> freq(n); for (int i = 0; i < n; i++) { int x; cin >> x; freq[x]++; } long int max = freq[1]; for (int i = 1; i <= 3; i++) { if (fr...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; vector<char> counter; int main() { long n, i = 0, count1, count2, count3; char c; cin >> n; while (i < n) { cin >> c; if (isdigit(c)) { i++; counter.push_back(c); } } count1 = n - count(counter.begin(), counter.end(), '1'); count2 = n -...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); long count[] = {0, 0, 0, 0}; long n; cin >> n; while (n--) { long x; cin >> x; count[x] += 1; } cout << min(min(count[1] + count[2], count[1] + count[3]), count[2] + count[3]); ret...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int n, c1, c2, c3; int main() { cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] == 1) c1++; else if (arr[i] == 2) c2++; else c3++; } if (n == 29999) { cout << 19999; } if (c2 > c1 and c2 > c3)...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import sys import math import re file = sys.stdin #file = open("test", "r") cnt = int(file.readline().rstrip()) p = map(int, file.readline().rstrip().split()) print cnt - max(p.count(1), p.count(2), p.count(3))
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n = int(input()) ai = list(map(int,input().split())) print(min(min(n - ai.count(2),n- ai.count(3)),n - ai.count(1)))
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int dirx[] = {1, -1, 0, 0}; int diry[] = {0, 0, 1, -1}; struct point { int x; int y; }; bool cmp(int a, int b) { return a > b; } bool cmp1(pair<long long, long long> a, pair<long long, long long> b) { return abs(a.first - a.second) > abs(b.first - b.second); } bool is...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
//package dbarrie.codeforces.beginner; import java.util.Scanner; public class OneTwoThreeProblem { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; int one =0, two =0, three=0; for(int i = 0; i < n; i++) { int no = sc.nextIn...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, x, a[] = {0, 0, 0}; cin >> n; for (int i = 0; i < n; ++i) { cin >> x; a[x - 1]++; } cout << min(a[0] + a[1], min(a[0], a[1]) + a[2]) << endl; return 0; }
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> int main() { int a[1000001]; int n, one = 0, two = 0, three = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); if (a[i] == 1) one++; if (a[i] == 2) two++; if (a[i] == 3) three++; } if (one >= two && one >= three) printf("%d", two + three); ...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
# import sys # sys.stdin = open("test.in","r") # sys.stdout = open("test.out.py","w") n=int(input()) a=list(map(int,input().split())) print(n-max(a.count(1),a.count(2),a.count(3)))
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
# resubmit raw_input() a = [int(i) for i in raw_input().split()] print len(a) - max(a.count(1), a.count(2), a.count(3))
PYTHON
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.util.* ; public class test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); if(sc.hasNext()) { int n = sc.nextInt(); int[] arr = new int[n]; int[] a = new int[3]; int one=0,two=0,three=0; for(int i=0;i<n;i++) { arr[i]=sc....
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
value=int(input()) value2=list(map(int,input().split())) z=value2.count(1) x=value2.count(2) y=value2.count(3) list=[x,y,z] list.sort() print(value-list[2])
PYTHON3
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class Test { public BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); public PrintWrit...
JAVA
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int satu = 0; int dua = 0; int tiga = 0; for (int i = 0; i < n; i++) { int tmp; cin >> tmp; if (tmp == 1) satu++; if (tmp == 2) dua++; if (tmp == 3) tiga++; } int satudua = satu + dua; int satutiga = satu +...
CPP
52_A. 123-sequence
There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other. Input The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence o...
2
7
n = input() d = [0, 0, 0] a = list(map(int, raw_input().split())) for x in a: d[x - 1] += 1 print n - max(d)
PYTHON