prompt string | response string |
|---|---|
Problem: 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 s... |
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class ProblemA_Test_1 {
final boolean ONLINE_JUDGE=System.getProperty("ONLINE_JUDGE")!=null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok=new StringTokenizer("");
void init() throws FileNotFoundException{
if (ONLINE_JU... |
Problem: 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 s... | import java.io.IOException;
import java.util.StringTokenizer;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.Collections;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Hash... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, tg, a = 0, b = 0, c = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> tg;
switch (tg) {
case 1:
a++;
break;
case 2:
b++;
break;
case 3:
c++;
break;
}
}
a = max(a, b... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
inline void pisz(int n) { printf("%d\n", n); }
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
for (int(i) = ... |
Problem: 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 s... |
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
public class IntT {
IntReader in;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = in.nui();
int[] ct = new int[3];
for(int i = 0;i < n;i++){
ct[... |
Problem: 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 s... | input()
a=list(map(int,input().split()))
k=a.count(1)
k2=a.count(2)
k3=a.count(3)
print(len(a)-max(k,k2,k3)) |
Problem: 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 s... | n=int(input())
s=input()
o=s.count('1')
t=s.count('2')
th=n-o-t
print(n-max(max(o,t),th)) |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int n, one, two, three;
int main() {
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
for (int i = 0; i < n; i++) {
if (arr[i] == 1) {
one++;
}
if (arr[i] == 2) {
two++;
}
if (arr[i] == 3) {
three++;
... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int a[3] = {0, 0, 0}, s;
int main() {
string n;
getline(cin, n);
string x;
getline(cin, x);
s = x.size();
s = (s + 1) / 2;
for (int i = 0; i < 2 * s - 1; i += 2) {
if (x[i] == '1') a[0]++;
if (x[i] == '2') a[1]++;
if (x[i] == '3') a[2]++;
}
cou... |
Problem: 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 s... | from statistics import mode
n = int(input())
list_of_numbers = [int(x) for x in input().split()]
m = mode(list_of_numbers)
print(n-list_of_numbers.count(m))
|
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, n, m, a, b1 = 0, b2 = 0, b3 = 0;
scanf("%d", &n);
j = n;
while (n--) {
scanf("%d", &a);
if (a == 1) b1++;
if (a == 2) b2++;
if (a == 3) b3++;
}
m = max(b1, b2);
m = max(m, b3);
printf("%d\n", j - m);
return 0;
}
|
Problem: 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 s... | import sys
n = int(sys.stdin.readline().strip())
a = sys.stdin.readline().strip().split()
def findMin(n,a):
nums = {'1':0,'2':0,'3':0}
for num in a:
nums[num]+=1
return min(nums['1']+nums['2'],nums['1']+nums['3'],nums['2']+nums['3'])
print(findMin(n,a))
|
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, aux;
cin >> n;
vector<int> a(3, 0);
for (int i = 0; i < n; i++) {
cin >> aux;
a[aux - 1]++;
}
sort(a.begin(), a.end());
cout << a[0] + a[1] << endl;
return 0;
}
|
Problem: 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 s... | n=int(raw_input())
l=raw_input().split().count
print min(l('1')+l('2'),l('1')+l('3'),l('2')+l('3')) |
Problem: 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 s... | n=int(input())
a=[int(j) for j in input().split()]
a.sort()
one,two,three=0,0,0
for i in a:
if i==1:
one=one+1
elif i==2:
two=two+1
elif i==3:
three=three+1
print(n-max(one,two,three)) |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
int input;
vector<long long> cnt, cnt2;
cnt.push_back(0);
cnt.push_back(0);
cnt.push_back(0);
for (long long i = 0; i < n; i++) {
scanf("%d", &input);
if (input == 1)
cnt[0]++;
else if (input == 2)
... |
Problem: 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 s... | x=int(input())
s=[int(n) for n in (input()).split()]
a=s.count(1)
b=s.count(2)
c=s.count(3)
z=int((a+b+abs(a-b))/2)
z=int((z+c+abs(z-c))/2)
print(x-z) |
Problem: 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 s... | n = input()
a = [int(x) for x in raw_input().split(" ")]
a1 = 0
a2 = 0
a3 = 0
for ai in a:
if ai == 1:
a1 += 1
elif ai == 2:
a2 += 1
elif ai == 3:
a3 += 1
if a1 >= a2 and a1 >= a3:
print a2 + a3
elif a2 >= a3 and a2 >= a1:
print a3 + a1
elif a3 >= a1 and a3 >= a2:
print a1 + a2 |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin >> n;
map<long long int, long long int> m;
for (long long int i = 0; i < n; i++) {
long long int x;
cin >> x;
m[x]++;
}
long long int maxi = -1;
for (auto it : m) {
if (maxi < it.second) maxi = it.second;
}
... |
Problem: 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 s... | import java.util.Scanner;
public class training_2 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int count = Integer.parseInt(scan.nextLine());
int a = 0;
int b = 0;
int c = 0;
for(char num:scan.nextLine().toCharArray()){
if(num=='1'){
a++;
}else if(num=='2')... |
Problem: 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 s... |
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Сергей
*/
pub... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
vector<char> counter;
int main() {
long n, i = 0, count1, count2, count3;
string sequence;
char c;
cin >> n;
while (i < n) {
cin >> c;
if (isdigit(c)) {
i++;
sequence += c;
}
}
counter.assign(sequence.begin(), sequence.end());
count1 ... |
Problem: 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 s... | n=int(input())
a=[int(x) for x in input().split()]
k=(a.count(1))
l=(a.count(2))
m=(a.count(3))
c=max(k,l,m)
print(k+l+m-c) |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int numOfNums;
cin >> numOfNums;
int o = 0, t = 0, th = 0;
for (int i = 0; i < numOfNums; i++) {
int number;
cin >> number;
if (number == 1) o++;
if (number == 2) t++;
if (number == 3) th++;
}
if (numOfNums == 2) {
cout << 1;... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const long long inf = 1ll << 60;
char grid[maxn][maxn];
int ps[maxn][2];
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n;
cin >> n;
vector<int> ap(3);
for (int i = 0; i < n; i++) {
int in;
cin >> in;
ap[i... |
Problem: 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 s... | n=int(input())
max1=1;count=0
ar=sorted(list(map(int,input().split())))
for i in range(n-1):
if ar[i]==ar[i+1]:
count+=1
else:
count=0
max1=max(max1,count+1)
print(n-max1) |
Problem: 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 s... | n = int(input())
l = list(map(int,input().split()))
freq = {}
for item in l:
if (item in freq):
freq[item] += 1
else:
freq[item] = 1
l = list(sorted(freq.values(),reverse=True))
l.remove(l[0])
print(sum(l))
|
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin >> n;
int numb = 0;
long long int count1 = 0, count2 = 0, count3 = 0;
for (long long int i = 0; i < n; i++) {
cin >> numb;
if (numb == 1) {
count1 += 1;
} else if (numb == 2) {
count2 += 1;
} else if (n... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
long long n, fq[4];
int main() {
long long i, k, mx = -1e18;
scanf("%lld", &n);
for (i = 0; i < n; i++) {
scanf("%lld", &k);
fq[k]++;
mx = max(mx, fq[k]);
}
printf("%lld\n", n - mx);
}
|
Problem: 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 s... | # bsdk idhar kya dekhne ko aaya hai, khud kr!!!
# import math
# from itertools import *
# import random
# import calendar
# import datetime
# import webbrowser
n = int(input())
arr = list(map(int, input().split()))
temp = list(dict.fromkeys(arr))
max_count = 0
value = 0
for i in temp:
if arr.count(i) > max_count:
... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int i, arr[3] = {0}, n, x;
cin >> n;
for (i = 0; i < n; i++) {
scanf("%d", &x);
arr[x - 1]++;
}
sort(arr, arr + 3);
cout << arr[0] + arr[1];
}
|
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int main() {
int n, k, s[5] = {0};
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> k;
s[k]++;
}
sort(s + 1, s + 4, cmp);
cout << n - s[1];
return 0;
}
|
Problem: 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 s... | /**
* Created by IntelliJ IDEA.
* User: piyushd
* Date: 1/5/11
* Time: 3:21 AM
* To change this template use File | Settings | File Templates.
*/
public class Sequence123 {
void run(){
int n = nextInt();
int[] seq = new int[n];
for(int i = 0; i < n; i++)
seq[i] = nextInt();
int[] num = new int[3]... |
Problem: 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 s... | n = int(input())
nums = [int(j) for j in input().split()]
ref = 3 * [0]
for j in range(n):
ref[nums[j] - 1] += 1
print(n - max(ref))
|
Problem: 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 s... | 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 (... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int max1(int i, int x) {
if (i > x) return i;
return x;
}
int n;
int a[3];
const int N = 1e6 + 5;
int main() {
int x;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &x);
a[x]++;
}
int m = 0;
for (int j = 1; j <= 3; j++) m = max1(m, a[j]);... |
Problem: 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 s... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class A {
public static void main(String args[]) throws IOException{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer s... |
Problem: 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 s... | import java.util.Scanner;
public class A52 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt(), one = 0, two = 0, three = 0, max;
for (int i = 0; i < n; i++) {
int a = scanner.nextInt();
if (a == 1) {
... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, ans = 0, x, mx = 0;
map<int, int> mp;
cin >> n;
set<int> st;
for (int i = 0; i < n; i++) {
cin >> x;
mp[x]++;
mx = max(mx, mp[x]);
st.insert(x);
}
for (auto it = st.begin(); it != st.end(); it++) {
if (mp[*it] <= mx) {
... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int one, two, three;
int main() {
int n, i, j, k, a, b;
cin >> n;
for (i = 0; i < n; i++) {
scanf("%d", &a);
if (a == 1)
one++;
else if (a == 2)
two++;
else
three++;
}
if (one && !two && !three)
printf("0");
else if (two && ... |
Problem: 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 s... | #!/usr/bin/python3
n=int( input().rstrip() )
A=list( map( int, input().split() ) )
B=[0,0,0,0]
for i in A:
B[i]+=1
ans=n-max(B)
print(ans) |
Problem: 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 s... | N = input()
mas = map(int, raw_input().split())
m = dict()
for i in mas:
if i in m:
m[i] += 1
else:
m[i] = 1
print N - max([m[i] for i in m]) |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int hasil(int a, int b) { return a > b ? a : b; }
int main() {
int input, angka, jml1, jml2, jml3, c;
jml1 = jml2 = jml3 = 0;
cin >> input;
int sama = input;
while (sama > 0) {
sama--;
cin >> angka;
if (angka == 1)
jml1++;
else if (angka == 2... |
Problem: 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 s... | #include <bits/stdc++.h>
int main() {
int n;
std::scanf("%d", &n);
int temp_n(n);
int ones(0), twos(0), threes(0);
int num;
while (temp_n--) {
std::scanf("%d", &num);
if (num == 1)
ones++;
else if (num == 2)
twos++;
else
threes++;
}
int max_num(std::max(ones, std::max(t... |
Problem: 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 s... | import java.util.Scanner;
public class A123Sequence {
public static void main(String[] args){
int n, one=0, two=0, three=0,ans =0, max=0;
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
int[] array = new int[n];
for(int i = 0; i < n; i++)
{
... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
struct all {
int a1 = 0;
int a2 = 0;
int a3 = 0;
} numere;
int m;
cin >> m;
for (int i = 0; i < m; i++) {
int x;
cin >> x;
if (x == 1) numere.a1++;
if (x == 2) numere.a2++;
if (x == 3) numere.a3++;
};
if (numere.a1 ... |
Problem: 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 s... | import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
public class Check2
{
static class InputReader
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;
... |
Problem: 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 s... | #include <bits/stdc++.h>
int main() {
int n, a, i, c1 = 0, c2 = 0, c3 = 0;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &a);
if (a == 1) {
c1++;
} else if (a == 2) {
c2++;
} else if (a == 3) {
c3++;
}
}
if (c1 >= c2 && c1 >= c3) {
printf("%d\n", n - c1);
}... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
int count[3] = {0};
for (int i = 0; i < n; ++i) {
cin >> a[i];
count[a[i] - 1]++;
}
int sum = 0;
int max = 0;
for (int i = 0; i < 3; ++i) {
if (count[i] > max) max = count[i];
sum += count[i];
}
c... |
Problem: 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 s... | n = int(input())
a = input().split(' ')
b = [0]*3
for i in a:
b[int(i)-1] += 1
print(n-max(b)) |
Problem: 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 s... | 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[] A = new int[n];
for(int i = 0;i < n;i++)
{
A[i] = x.nextInt();
if(A[i] == 1)c1++;
if(A[i] == 2)c2++;
if(A[i] == 3)c3++;
... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
while (cin >> n) {
int i, a[n], b[3] = {0};
for (i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == 1) b[0]++;
if (a[i] == 2) b[1]++;
if (a[i] == 3) b[2]++;
}
int max = 0;
for (i = 1; i < 3; i++) {
if (b[i... |
Problem: 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 s... | import com.sun.corba.se.impl.orbutil.graph.NodeData;
import org.w3c.dom.NodeList;
import java.awt.*;
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.io.PrintWriter;
impo... |
Problem: 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 s... | //package codeforces.codeforces.A;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String []args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int []arr= new int[4];
for(int i=0;i<n;i++)
arr[sc.nextInt(... |
Problem: 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 s... |
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringToken... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3] = {0};
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int x;
scanf("%d", &x);
arr[x - 1]++;
}
sort(arr, arr + 3);
cout << arr[0] + arr[1] << endl;
}
|
Problem: 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 s... | n = input().split()
a = list(map(int,input().split()))
num = [0] * 4
for i in a:
num[i]+=1
num.sort()
res = 0
res = num[1]+num[2]
print(res)
|
Problem: 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 s... | 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... |
Problem: 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 s... | n=int(input())
# a=list(int(input()))
a=input()
a=a.split(' ')
for i in range(n):
a[i]=int(a[i])
# count_num=[0 0 0]
# for i in range(n):
# if a[i]==1:
# count[0]+=1
# elif a[i]==2:
# count[1]+=1
# elif a[i]==3:
# count[2]+=1
count_123=[0,0,0]
for i in range(1,4):
co... |
Problem: 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 s... | import java.util.*;
import java.io.*;
public class One{
public static void main(String[] args) throws Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
br.readLine();
String in... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int color[1001];
int main() {
int n, p;
while (cin >> n) {
vector<int> vec;
int one = 0;
int two = 0;
int three = 0;
for (int i = 0; i < n; i++) {
cin >> p;
if (p == 1) one++;
if (p == 2) two++;
if (p == 3) three++;
}
... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int n, a[4] = {0};
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
int x;
scanf("%d", &x);
a[x]++;
}
int mx = 0, id;
for (int i = 1; i <= 3; ++i)
if (a[i] > mx) {
mx = a[i];
id = i;
}
int ans = 0;
for (int i = 1; i <... |
Problem: 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 s... |
import java.awt.Point;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.Arr... |
Problem: 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 s... | from sys import stdin
def read_lines(sep=' ', input_type=None):
#list of rows
_lines = stdin.readlines()
cast = input_type is not None
lines = []
for line in _lines:
line = line[:-1].split(sep)
if cast:
line = [input_type(x) for x in line]
lines.append(line)
... |
Problem: 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 s... | n, t = int(raw_input()), raw_input()[:: 2]
a, b = t.count('1'), t.count('2')
print n - max(a, b, n - a - b) |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int a[1000001];
int b[4];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
b[a[i]]++;
}
int max = 0;
for (int i = 1; i <= 3; i++) {
if (b[i] > max) max = b[i];
}
printf("%d\n", n - max);
return 0;
}
|
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, i;
cin >> n;
int cnt[4] = {0};
for (i = 0; i < n; i++) {
cin >> x;
if (x == 1)
cnt[1]++;
else if (x == 2)
cnt[2]++;
else if (x == 3)
cnt[3]++;
}
int y, z;
x = max(cnt[1], cnt[2]);
y = max(x, cnt[3]);
... |
Problem: 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 s... | import java.io.*;
import java.util.*;
import java.util.stream.IntStream;
public class CodeForces {
public static void main(String[] args) {
FastIO io = FastIO.create();
int n = io.nextInt();
int[] c = new int[4];
int max = 0;
for (int i = 0; i < n; i++) {
int... |
Problem: 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 s... | #include <bits/stdc++.h>
int main() {
int a[1000002], i, p = 0, q = 0, r, max, n;
scanf("%d", &n);
for (i = 0; i < n; i++) scanf("%d", &a[i]);
for (i = 0; i < n; i++) {
if (a[i] == 1)
p++;
else if (a[i] == 2)
q++;
}
r = n - (p + q);
max = p > q && p > r ? p : q > r ? q : r;
printf("\... |
Problem: 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 s... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
/**
* Created by wencan on 2015/6/4.
*/
public class Atest {
public static void main(String[] args) throws IOException {
Atest atest = new Atest();
atest... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin >> n;
long long int a[n];
long long int b[4] = {0};
for (int i = 0; i < n; i++) {
cin >> a[i];
b[a[i]]++;
}
sort(b, b + 4);
cout << b[1] + b[2] << endl;
return 0;
}
|
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int n, x, o = 0, t = 0, th = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x;
switch (x) {
case 1:
o++;
break;
case 2:
t++;
break;
... |
Problem: 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 s... | import java.io.*;
import java.util.*;
public class Main {
//SOLVE........................................
void solve() throws IOException {
int n = nextInt();
int[] arr = new int[3];
for( int i = 0; i < n; i++ )
arr[nextInt()-1]++;
int max = Math.max(Math.max(arr[... |
Problem: 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 s... | import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.io.BufferedReader;
public class Main {
static StreamTokenizer st;
private static int nextInt() throws IOException{
st.nextToken();
return (int) st.nval;
}
public static void main(String[] args)... |
Problem: 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 s... | n = int(raw_input().strip())
L = map(int, raw_input().strip().split())
x = [0, 0, 0]
for i in range(n):
x[L[i] - 1] = x[L[i] - 1] + 1
print min(x[0] + x[1], x[1] + x[2], x[2] + x[0])
|
Problem: 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 s... | import java.util.*;
public class sequence123 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[] c = new int[3];
for (int i = 0; i < n; i++) {
c[scan.nextInt() - 1]++;
}
System.out.println(c[0] +... |
Problem: 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 s... | #include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
void test_case() {
int n;
cin >> n;
vector<int> arr(n);
int a[4] = {0, 0, 0, 0};
for (int &x : arr) {
cin >> x;
a[x]++;
}
int mx = *max_element(a, a + 4);
cout << n - mx << '\n';
}
int main() {
cin.tie(0);
ios_base::syn... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, s[4];
memset(s, 0, sizeof(s));
cin >> n;
for (int x, i = 1; i <= n; i++) {
cin >> x;
s[x]++;
}
cout << n - max(s[1], max(s[2], s[3]));
}
|
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k[3] = {0, 0, 0};
cin >> n;
int x;
for (int i = 0; i < n; i++) {
cin >> x;
k[x - 1]++;
}
cout << min(n - k[0], min(n - k[1], n - k[2]));
}
|
Problem: 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 s... | import java.util.Scanner;
public class Sequance {
private static final String Syst = null;
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int[] arr =new int[4];
int n =Integer.parseInt(input.nextLine());
Stri... |
Problem: 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 s... | def main():
n = int(raw_input())
cnt = [0] * 4
num = map(int, raw_input().split())
for i in range(0, n):
cnt[num[i]] += 1
ans = 100000000
for i in range(1, 4):
if ans > (n - cnt[i]):
ans = n - cnt[i]
print ans
return 0
if __name__ == '__main__'... |
Problem: 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 s... |
import java.util.Arrays;
import java.util.Scanner;
public class A52 {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int[] array = new int[a];
int x = 0;
int y = 0;
int z = 0;
for (int i = 0; i < array.len... |
Problem: 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 s... | n = int(input())
def process(A):
d = [0, 0, 0]
for x in A:
d[x-1]+=1
return sum(d)-max(d)
A = [int(x) for x in input().split()]
print(process(A)) |
Problem: 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 s... | import java.util.*;
import java.io.*;
public class Araro{
public static void main(String args[]) throws IOException{
BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
String tmp = lector.readLine();
tmp = lector.readLine();
int a[] = {0,0,0};
int sum = 0;
for(int n = 0;n<tmp.length();n+=2){
... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int one = 0, two = 0, three = 0, n, m = 0;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
if (arr[i] == 1) {
one++;
} else if (arr[i] == 2) {
two++;
} else {
three++;
}
}
m = max(one, max(two... |
Problem: 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 s... | #include <bits/stdc++.h>
using std::max;
inline long long read() {
long long x = 0, f = 1;
char c = getchar();
for (; !isdigit(c); c = getchar())
if (c == '-') f = -1;
for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + c - '0';
return x * f;
}
long long t[5], n, x;
int main() {
n = read();
wh... |
Problem: 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 s... |
import java.util.Scanner;
public class A123Sequence {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
int n = input.nextInt();
int one = 0 , two = 0 , three = 0;
String h = input.next();
String k = input.nextLine();
h += k;
... |
Problem: 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 s... | n = int(input())
a = list(map(int, input().split()))
v = []
for i in [1,2,3]:
v.append(a.count(i))
print(len(a) - max(v)) |
Problem: 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 s... | n = int(raw_input())
s = raw_input()
m = map(int, s.split())
l = [0, 0, 0]
k1 = 0
k2 = 0
k3 = 0
for i in xrange(0, n):
k = m[i]
if k == 1:
l[0] += 1
elif k == 2:
l[1] += 1
else:
l[2] += 1
p = max(l)
print(n - p) |
Problem: 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 s... | #include <bits/stdc++.h>
const int MOD = 1e9 + 7;
int primes[100000];
using namespace std;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n;
cin >> n;
int arr[n];
int count1 = 0, count2 = 0, count3 = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
if (arr[i] == 1) {
co... |
Problem: 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 s... | input()
c=raw_input().count
a,b,c=c('1'),c('2'),c('3')
print min(a+b,b+c,a+c) |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int cnt[3] = {};
while (n--) {
int val;
cin >> val;
cnt[val - 1]++;
}
cout << min(cnt[0] + cnt[1], min(cnt[0] + cnt[2], cnt[1] + cnt[2])) << endl;
return 0;
}
|
Problem: 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 s... | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
FastScanner input = new FastScanner();
int N = input.nextI... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, arr[4] = {0}, a, max = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a;
arr[a]++;
}
for (int i = 1; i <= 3; i++) {
if (arr[i] > max) max = arr[i];
}
cout << n - max << endl;
return 0;
}
|
Problem: 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 s... | N = int(input())
A = list(map(int, input().split()))
counter = [0, 0, 0]
for i in range(0, N):
counter[A[i]-1] += 1
counter.sort()
print(counter[0]+counter[1]) |
Problem: 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 s... | import java.util.Scanner;
public class OneTwoThreeSequence {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = Integer.parseInt(input.nextLine());
String line = input.nextLine();
int[] nums = new int[n];
for (int i = 0; i < n; i++) {
... |
Problem: 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 s... | import java.util.*;
import java.io.*;
public class seq123{
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int[] freq = new int[3];
int n = Integer.parseInt(br.readLine());
String line = br.readLine... |
Problem: 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 s... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
int b[3];
for (int i = 0; i < 3; i++) b[i] = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
b[a[i] - 1]++;
}
for (int i = 1; i <= 3; i++)
for (int j = 0; j < 2; j++)
if (b[j] > b[j + 1]) swap(b[j], b[j... |
Problem: 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 s... | def mce(v,n):
"""max count element"""
d=dict()
for c in v:
d.setdefault(c,0)
d[c]+=1
return n-max(d.values())
n=int(input())
v=[int(c) for c in input().split()]
print(mce(v,n)) |
Problem: 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 s... | import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Zyflair Griffane
*/
public ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.