-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.java
More file actions
98 lines (76 loc) · 3.45 KB
/
Copy pathA.java
File metadata and controls
98 lines (76 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
/$$$$$ /$$$$$$ /$$ /$$ /$$$$$$
|__ $$ /$$__ $$| $$ | $$ /$$__ $$
| $$| $$ \ $$| $$ | $$| $$ \ $$
| $$| $$$$$$$$| $$ / $$/| $$$$$$$$
/$$ | $$| $$__ $$ \ $$ $$/ | $$__ $$
| $$ | $$| $$ | $$ \ $$$/ | $$ | $$
| $$$$$$/| $$ | $$ \ $/ | $$ | $$
\______/ |__/ |__/ \_/ |__/ |__/
/$$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$ /$$ /$$$$$$$$ /$$$$$$$
| $$__ $$| $$__ $$ /$$__ $$ /$$__ $$| $$__ $$ /$$__ $$| $$$ /$$$| $$$ /$$$| $$_____/| $$__ $$
| $$ \ $$| $$ \ $$| $$ \ $$| $$ \__/| $$ \ $$| $$ \ $$| $$$$ /$$$$| $$$$ /$$$$| $$ | $$ \ $$
| $$$$$$$/| $$$$$$$/| $$ | $$| $$ /$$$$| $$$$$$$/| $$$$$$$$| $$ $$/$$ $$| $$ $$/$$ $$| $$$$$ | $$$$$$$/
| $$____/ | $$__ $$| $$ | $$| $$|_ $$| $$__ $$| $$__ $$| $$ $$$| $$| $$ $$$| $$| $$__/ | $$__ $$
| $$ | $$ \ $$| $$ | $$| $$ \ $$| $$ \ $$| $$ | $$| $$\ $ | $$| $$\ $ | $$| $$ | $$ \ $$
| $$ | $$ | $$| $$$$$$/| $$$$$$/| $$ | $$| $$ | $$| $$ \/ | $$| $$ \/ | $$| $$$$$$$$| $$ | $$
|__/ |__/ |__/ \______/ \______/ |__/ |__/|__/ |__/|__/ |__/|__/ |__/|________/|__/ |__/
*/
import java.io.*;
import java.util.*;
import java.math.*;
public class cf
{
// static class pair{
// long x;
// Long y;
// public pair(long x,long y){
// this.x=x;
// this.y=y;
// }
// }
static int dp[][];
static int solve(String s1,String s2,int n,int m){
if(n<=0 || m<=0)
return 0;
if(dp[n][m]!=-1)
return dp[n][m];
if(s1.charAt(n-1)==s2.charAt(m-1)){
return dp[n][m]=solve(s1,s2,n-1,m-1)+2;
}
else{
return dp[n][m]= Math.max(solve(s1,s2,n-1,m)-1,solve(s1,s2,n,m-1)-1);
}
}
public static void main(String args[]) throws IOException
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int a[]=new int[n];
HashMap<Integer,Integer> map=new HashMap<>();
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
if(map.containsKey(a[i])==true)
map.put(a[i],map.get(a[i])+1);
else{
map.put(a[i],1);
}
}
boolean f=true;
for(Map.Entry<Integer,Integer> mp:map.entrySet()){
int x=mp.getKey();
int y=mp.getValue();
int z=(int)Math.ceil(n/2.0);
if(y>z){
f=false;
break;
}
}
if(f){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}
}