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
#include <bits/stdc++.h> using namespace std; int main() { int x = 0; cin >> x; int array[x]; for (int i = 0; i < x; i++) { cin >> array[i]; } int one = 0, two = 0, three = 0; for (int j = 0; j < x; j++) { if (array[j] == 1) { one++; } if (array[j] == 2) { two++; } 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
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const int MAX = numeric_limits<int>::max(); int main() { int n; scanf("%d", &n); vector<int> v(3, 0); for (int i = 0; i < n; ++i) { int t; scanf("%d", &t); ++v[t - 1]; } int m = 0; for (int i = 0; i < 3; ++i) { if (v[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.HashMap; import java.util.Scanner; public class CF52A { public static void main(String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); int max_freq=0; HashMap<Integer,Integer> hm=new HashMap<>(); for(int i=0;i<n;i++){ int num=s.nex...
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
a=input() b=raw_input() string = map(int, b.split()) d={} for i in string: if i in d: d[i]+=1 else: d[i]=1 print a-d[max(d,key=d.get)]
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(raw_input()) a = map(int, raw_input().split()) print min(a.count(1)+a.count(2), a.count(3)+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
n=input() L=input() o=L.count('1') t=L.count('2') th=L.count('3') L=[o,t,th] L.sort() print(L[0]+L[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())) 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
import java.util.*; public class A52 { public static void main(String aa[]) { Scanner ob=new Scanner(System.in); int n,a=0,b=0,c=0,d=0,i,p; n=ob.nextInt(); for(i=0;i<n;i++) { p=ob.nextInt(); if(p==1) {a++;continue;} ...
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() { ios::sync_with_stdio(false); long iLength, n1 = 0, n2 = 0, n3 = 0, i; int iInput; cin >> iLength; for (i = 1; i <= iLength; ++i) { cin >> iInput; switch (iInput) { case 1: ++n1; break; case 2: ++n2; ...
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, count1 = 0, count2 = 0, count3 = 0; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] == 1) { count1++; } if (arr[i] == 2) { count2++; } if (arr[i] == 3) { count3++; } } ...
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 Sequence52A { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int a[] = new int[n]; for(int i=0;i<n;i++) { a[i] = sc.nextInt(); } int k=0,l=0,m=0; for(int i=0;i<n;i++) { if(a[i] == 1) k++; else if(a[...
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.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Reader; import java.io.StreamTokenizer; import java.io.Writer; import java.util.Arrays; public...
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 n, a[4], c; int main() { cin >> n; for (int i = 1; i <= n; i++) scanf("%d", &c), a[c]++; cout << n - max(max(a[1], a[2]), 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 max(int x, int y) { if (x > y) return x; else return y; } int main() { int n; while (cin >> n) { int a; int c1 = 0, c2 = 0, c3 = 0; for (int i = 1; i <= n; i++) { cin >> a; if (a == 1) c1++; else if (a == 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
import java.io.*; import java.util.*; public class Main { static class Assert { static void check(boolean e) { if (!e) { throw new Error(); } } } static class Scanner { StreamTokenizer in; Scanner(Reader r) { in = new StreamTokenizer(new BufferedReader(r)); in.resetSyntax(); ...
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()) l=input().split() c1,c2,c3=l.count('1'),l.count('2'),l.count('3') print(min(c1+c2,c2+c3,c3+c1))
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.awt.Point; import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Double.parseDouble; import static java.lang.String.*; public class Main { static StringBuilder...
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
# 123-sequence import collections n = int(raw_input()) count = collections.Counter(x for x in raw_input().split()) print n-count.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
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Scanner; import java.util.StringTokenizer; public class CF_52_A_123_SEQUENCE { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.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; int hashh[100005]; int main() { memset(hashh, 0, sizeof(hashh)); int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int temp; scanf("%d", &temp); hashh[temp]++; } int ans = 0; int count = INT_MIN; for (int i = 0; i < 100003; i++) { if (cou...
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.util.Arrays; import java.util.StringTokenizer; public class Codeforces { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new Buf...
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()) seq = list(map(int, input().split())) print(n - max(seq.count(x) for x in [1,2,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
n, t = int(input()), input()[:: 2] a, b = t.count('1'), t.count('2') print(n - max(a, b, n - a - b))
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.InputStreamReader; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))); int n = sc.nextInt(); String input; int num[...
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 n, a[9999999], d1, d2, d3; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] == 1) d1++; if (a[i] == 2) d2++; if (a[i] == 3) d3++; } int res = max(max(d1, d2), d3); cout << n - res; }
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().strip().split())) x = arr.count(1) y = arr.count(2) z = arr.count(3) ans1 = max(x,y) ans2 = max(ans1,z) print(len(arr)-ans2)
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 sys n_nums = int(sys.stdin.readline()) values = [int(x) for x in sys.stdin.readline().split()] one, two, three = 0, 0, 0 for i in values: if i == 1: one += 1 if i == 2: two += 1 if i == 3: three += 1 result = one + two + three - max(one, two, three) print(result)
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
total_number=int(input()) my_list=input() user_list=my_list.split() a, b, c = 0, 0, 0 for num in user_list: if int(num)==1: a+=1 elif int(num)==2: b+=1 elif int(num)==3: c+=1 d=max(a,b,c) print (total_number-d)
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 (int x, i = 1; i <= n; i++) scanf("%d", &x), s[x]++; cout << n - max(s[1], max(s[2], s[3])); }
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.PrintWriter; import java.util.StringTokenizer; public class Main { void solve() throws IOException { int n = nextInt(); int[] sum = {0,0,0,0}; for (int i = 0; i < n; i++) { sum[nextInt()]++; } ...
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 sys import math n = int(sys.stdin.readline()) an = [int(x) for x in (sys.stdin.readline()).split()] v = [0] * 4 vall = 0 for i in an: vall += 1 v[i] += 1 print(vall - 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
n=int(input()) arr = [int(i) for i in input().split()] a=arr.count(1) b=arr.count(2) c=arr.count(3) min=b+c if min>(a+c): min=a+c if min>(a+b): min=a+b print(min)
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[1000005], cnt1, cnt2, cnt3, n, k; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { if (a[i] == 1) cnt1++; if (a[i] == 2) cnt2++; if (a[i] == 3) cnt3++; } k = max(cnt1, max(cnt2, cnt3)); cout << n - k...
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=map(int, raw_input().split()) q1,q2,q3=0,0,0 for i in a: if i==1: q1+=1 elif i==2: q2+=1 elif i==3: q3+=1 s1=q2+q3 s2=q1+q3 s3=q1+q2 if s1<=s2 and s1<=s3: print s1 elif s2<=s1 and s2<=s3: print s2 else: print 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 main() { long long int n, x; cin >> n; int arr[4] = {0}; for (int i = 0; i < n; i++) { cin >> x; arr[x]++; } sort(arr + 1, arr + 4); cout << arr[1] + arr[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
#include <bits/stdc++.h> using namespace std; template <typename S, typename T> ostream& operator<<(ostream& out, const pair<S, T> p) { out << "(" << p.first << "," << p.second << ")"; return out; } template <typename T> ostream& operator<<(ostream& out, const vector<T>& v) { for (auto a : v) out << a << " "; r...
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(); nums = [int(i) for i in input().split()]; ones = nums.count(1); twos = nums.count(2); threes = nums.count(3); x = max(ones, twos, threes); print(ones + twos + threes - x);
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
m=input() l=input() o=l.count('1') t=l.count('2') th=l.count('3') l=[o,t,th] l.sort() print(l[0]+l[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
total_number=input() my_list=input() user_list=my_list.split() a=user_list.count('1') b=user_list.count('2') c=user_list.count('3') d=max(a,b,c) print (int(total_number)-d)
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()) l=raw_input().count print min(l('1')+l('2'),l('1')+l('3'),l('2')+l('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
input() nums = input().split() print(min([len(nums)-nums.count("1"), len(nums)-nums.count("2"), len(nums)-nums.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
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class A52 { public static void main(String[] args) throws Exception{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int num...
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
//package geometry; import java.io.*; import java.util.*; import java.util.Map.Entry; import java.text.*; import java.math.*; import java.util.regex.*; import java.awt.Point; /** * * @author prabhat // use stringbuilder,TreeSet, priorityQueue */ public class point4{ public static long[] BIT; public stati...
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 Code { public static void main(String[] args) { Scanner in = new Scanner(System.in); int a = Integer.parseInt(in.nextLine().trim()); String b = in.nextLine().replace(" ", ""); int co1=Car(b, "1"); int co2=Car(b,"2"); int co3=Car(b,"3...
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 n, s[4]; int main() { scanf("%d", &n); for (int x, i = 1; i <= n; i++) scanf("%d", &x), s[x]++; cout << n - max(s[1], max(s[2], s[3])); }
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 = raw_input() k = [int(x) for x in raw_input().split()] w = len(filter(lambda x: x == 1 , k)) y = len(filter(lambda x: x == 2 , k)) z = len(filter(lambda x: x == 3 , k)) b = max(w,y,z) print int(n) - b
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 Sequence{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); scan.nextLine(); int[] c = new int[3]; String[] nums = scan.nextLine().split(" "); for(int i = 0; i < n; i++) c[Integer.parseInt(nums[i]) - 1] += 1; int ma...
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 = raw_input() s = raw_input() d = {} for i in s.split(): d[i] = d.get(i, 0) + 1 print sum(d.values()) - 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
a = int(input()) t = list(map(int,input().split())) g = set(t) p=[] for f in g: p.append(t.count(f)) print(sum(p)-max(p))
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.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Iterator...
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 count1 = 0, count2 = 0, count3 = 0; int N; cin >> N; for (int i = 0; i < N; i++) { int t; cin >> t; if (t == 1) count1++; if (t == 2) count2++; if (t == 3) count3++; } int ans = count1 + count2 + count3 - max(count1, max(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
n=input() a=input() x=a.count('1') y=a.count('2') z=a.count('3') a=[x,y,z] a.sort() print(a[0]+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
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # IN THE NAME OF GOD # C++ : Done.! # Python 3 : Loading... import math import random import sys import time #----------------------------------> Programmer : Kadi <-----------------------...
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.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int a[]=new int[4]; for(int i=0;i<n;i++){ a[sc.nextInt()]++; } int max=-2; for(int i=1;i<=3;i++){ if(a[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
import java.util.*; import java.io.*; public class Seq123 { public static void main(String[] args) throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); int[] count = new int[4]; String s = in.readLine(); StringTokenizer st = 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
#include <bits/stdc++.h> int n; int list[1000010]; int cnt[5]; int Max(int a, int b) { return a > b ? a : b; } int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &list[i]); int cnt1 = 0, cnt2 = 0, cnt3 = 0; for (int i = 1; i <= n; ++i) cnt[list[i]] += 1; printf("%d\n", n - Max(cnt[1], 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
from collections import Counter n = int(input()) xs = input().split() maxfreq = Counter(xs).most_common(1)[0][1] print(n - maxfreq)
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()) data = map(int,raw_input().split()) data.sort() one = 0 two = 0 three = 0 for i in range(n): if data[i]==1: one = one +1 if data[i]==2: two = two +1 if data[i]==3: three = three+1 print min(one+two,one+three,two+three)
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
inp = int(input()) a = [int(i) for i in input().split()] diction = dict() for letter in a: diction[letter] = diction.get(letter, 0) + 1 print(inp - max(diction.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
n, a = input (), map (int, raw_input ().split ()) print min (a.count (1) + a.count (2), a.count (1) + a.count (3), 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
#include <bits/stdc++.h> using namespace std; const long double epsilon = 1e-9; int main() { vector<int> mat(3); int n; cin >> n; int x; for (int i = 0; i < n; i++) { cin >> x; mat[x - 1]++; } int maxm = 0; for (int i = 0; i < 3; i++) maxm = max(maxm, mat[i]); cout << n - maxm << endl; retur...
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, x, o = 0, t = 0, th = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &x); switch (x) { case 1: o++; break; case 2: t++; break; case 3: th++; } } cout << (n - 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
n = int(input()) a = list(map(int, input().split())) x = a.count(1) y = a.count(2) z = a.count(3) print(n - max(x, y, z))
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.util.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int a[] = new int[n]; int result[] = new int[4]; Arrays.fill(result, 0); for (int i = 0; i < n; 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
input() s = input().split() print(len(s)-max(s.count("1"),s.count("2"),s.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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * Date 19.11.2011 * Time 22:39:40 * Author Woodey * $ */ public class A1 { private void Solution() throws IOException { int n = nextInt(); int[] mas = new int[3]; for (int 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
import java.io.*; import java.math.*; import java.util.*; import java.util.List; import java.util.Queue; import java.awt.*; public class codefors implements Runnable { private BufferedReader br = null; private PrintWriter pw = null; private StringTokenizer stk = new StringTokenizer(""); public static...
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.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int a[]= new int[n]; for (int i=0;i<n;i++){ a[...
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 freq[4]; int main() { int n, x; cin >> n; for (int i = 0; i < n; i++) { cin >> x; freq[x]++; } sort(freq, freq + 4); cout << abs(freq[3] - n) << 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 max(int a, int b, int c) { int x = c + b, y = a + c, z = a + b; if (x <= y && x <= z) cout << x << endl; else if (z <= y && x >= z) cout << z << endl; else if (x >= y && y <= z) cout << y << endl; return 0; } int main() { int n, a = 0, b = 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
#include <bits/stdc++.h> using namespace std; int main() { int x = 0, q = 0, a[3] = {0, 0, 0}; scanf("%d", &x); for (int i = 0; i < x; i++) { scanf("%d", &q); if (q == 1) { a[0]++; } else if (q == 2) { a[1]++; } else if (q == 3) { a[2]++; } } int max = 0; for (int i = 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.text.DecimalFormat; public class A { static BufferedReader IN; static { try { // IN = new BufferedReader(new FileReader(new File(A.class.getResource("a1.txt").toURI()))); IN = ...
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
stdin_flag=1 if not stdin_flag: read_line_index=0 testcasefilename="test.txt" Stestcase=open(testcasefilename).read() read_line_datas=Stestcase.split("\n") def debugs(s): if not stdin_flag: print ";;;",s def puts(s): import sys sys.stdout.write(str(s)) ##################################### #####...
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.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class A052 { public static void main(String[] args) throws Exception { BufferedReader r= new BufferedReader(new InputStreamReader(System.in)); int n= Integer.parseInt(r.readLine()); int[] ar = new int[4]; ...
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.BufferedInputStream; import java.util.Scanner; public class Sequence123 { //Testing Round #1 - 123-sequence public static void main(String[] args) { Scanner sc = new Scanner(new BufferedInputStream(System.in)); int[] numXs = new int[3]; int numInts = sc.nextInt(); for(int i = 0; i < numInts; ...
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()) z=list(map(int,input().split())) one=0 two=0 three=0 for i in z : if i==1 : one+=1 elif i==2 : two+=1 else : three+=1 if one > two and one > three : print(n-one) elif two>one and two >three : print(n-two) elif three>one and three>two : print(n-three) els...
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
total = int(input()) c1 = 0 c2 = 0 c3 = 0 for i in input().split(): if i == '1': c1 += 1 elif i == '2': c2 += 1 elif i == '3': c3 += 1 print(total - max(max(c1,c2),c3))
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=input() print(n-max(a.count(x)for x in '123'))
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.util.*; public class CF102 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t=sc.nextInt(); int[] ar=new int[t]; int[] count=new int[4]; for(int i=0;i<t;i++){ int num=sc.nextInt(); count[num]++; }...
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
x = raw_input() y = raw_input().split() y = sorted(y) y = map(int, y) c1 = y.count(1) c2 = y.count(2) c3 = y.count(3) if c1>=c2 and c1>=c3: print c2+c3 elif c2>=c1 and c2>=c3: print c1+c3 elif c3>=c1 and c3>=c2: print c1+c2
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; scanf("%d", &n); int cont[4]; memset(cont, 0, sizeof cont); for (int i = 0, a; i < n; ++i) { scanf("%d", &a); ++cont[a]; } int ans = n; for (int i = 1; i <= 3; ++i) ans = min(ans, cont[1] + cont[2] + cont[3] - cont[i]); prin...
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=[int(ii) for ii in input().split()] cnt=[0]*5 for i in a: cnt[i]+=1 print(len(a)-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
#include <bits/stdc++.h> using namespace std; int a[1000005]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int b[5] = {0, 0, 0, 0, 0}; for (int i = 0; i < n; i++) { if (a[i] == 1) b[1]++; else if (a[i] == 2) b[2]++; else if (a[i] == 3) b[3]++; } sort...
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.util.Arrays; import java.util.StringTokenizer; public class Main { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { // TODO Aut...
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()) L=[0,0,0] M=list(map(int,input().split())) for i in range(0,n): if(M[i]==1): L[0]+=1 elif(M[i]==2): L[1]+=1 else: L[2]+=1 L.sort() print(L[0]+L[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
import sys from array import array # noqa: F401 def input(): return sys.stdin.buffer.readline().decode('utf-8') n = int(input()) a = list(map(int, input().split())) print(n - max(a.count(i) for i in range(1, 4)))
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()) seq = list(map(int,input().strip().split(' '))) print(n - max([seq.count(1),seq.count(2),seq.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
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class seq { static class Scanner { StringTokenizer st; BufferedReader br; ...
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 Slotuin { public static void main(String[] args) { Scanner x = new Scanner(System.in); int c1 = 0,c2 = 0,c3 = 0; int n = x.nextInt(); int z = 0; for(int i = 0;i < n;i++) { z = x.nextInt(); if(z == 1)c1++; if(z == 2)c2++; if(z == 3)c3++; } int d = Math.max(c1...
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.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()) secuencia = input().split() c1 = 0 c2 = 0 c3 = 0 for i in range(n): if secuencia[i] == '1': c1 = c1+1 elif secuencia[i] == '2': c2 = c2+1 else: c3 = c3+1 maximo = max(c1,c2,c3) rpta = c1+c2+c3 - maximo print(rpta)
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 maax(vector<int> w) { int temp = -1; for (int k = 0; k < w.size(); k++) { if (w[k] > temp) { temp = w[k]; } } return temp; } int main() { bool b = false; bool n = false; vector<int> e(3); e[0] = 0; e[1] = 0; e[2] = 0; int x = 0; cin...
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.*; import java.util.*; public class A { String line; StringTokenizer inputParser; BufferedReader is; FileInputStream fstream; DataInputStream in; void openInput(String file) { if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin else { try{ fstrea...
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()) l=list(map(int,input().split())) li=[l.count(1),l.count(2),l.count(3)] li.sort() print(li[0]+li[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
import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.io.Writer; import java.math.BigInteger; import java.io.InputStream; /** *...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n × n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; struct SegmentMaxTree { SegmentMaxTree(int default_value, int n) : default_value(default_value) { sz = 1; while (sz < n) { sz = sz << 1; } items.resize(2 * sz - 1, default_value); } void Set(int first, int last, int value) { return Set(first,...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n × n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.util.*; import java.math.*; import java.io.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; public class Main{ // ArrayList<Integer> lis = new ArrayList<Integer>(); // ArrayList<String> lis = new ArrayList<String>(); // Priority...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n × n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
import java.util.HashSet; import java.util.Map.Entry; import java.util.Scanner; import java.util.TreeMap; public class C { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int Q = in.nextInt(); int [] start = new int[Q]; boolean [] isup = new boolean[Q]; ...
JAVA
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n × n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; const int MOD(1000000007); const int INF((1 << 30) - 1); const int MAXN(200005); int x[MAXN], y[MAXN], numx[MAXN], numy[MAXN], t[2][4 * MAXN]; char c[MAXN]; map<int, int> tx, ty, kx, ky; map<pair<int, int>, bool> used; void init(int i, int f, int l, int c) { t[c][i] = -IN...
CPP
555_C. Case of Chocolate
Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n × n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to right and the rows are ...
2
9
#include <bits/stdc++.h> using namespace std; constexpr int MAXN = 1 << 30; struct tournament { struct Node { Node* parent; set<int, greater<int>> blocked; Node* left = nullptr; Node* right = nullptr; Node(Node* parent) : parent(parent) {} }* root = new Node(nullptr); set<int, greater<int>>::i...
CPP