File tree Expand file tree Collapse file tree 1 file changed +106
-0
lines changed Expand file tree Collapse file tree 1 file changed +106
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .util .*;
2
+ import java .lang .*;
3
+ import java .io .*;
4
+
5
+ class Codechef
6
+ {
7
+ static class FastReader
8
+ {
9
+ BufferedReader br ;
10
+ StringTokenizer st ;
11
+
12
+ public FastReader ()
13
+ {
14
+ br = new BufferedReader (new
15
+ InputStreamReader (System .in ));
16
+ }
17
+
18
+ String next ()
19
+ {
20
+ while (st == null || !st .hasMoreElements ())
21
+ {
22
+ try
23
+ {
24
+ st = new StringTokenizer (br .readLine ());
25
+ }
26
+ catch (IOException e )
27
+ {
28
+ e .printStackTrace ();
29
+ }
30
+ }
31
+ return st .nextToken ();
32
+ }
33
+
34
+ int nextInt ()
35
+ {
36
+ return Integer .parseInt (next ());
37
+ }
38
+
39
+
40
+ long nextLong ()
41
+ {
42
+ return Long .parseLong (next ());
43
+ }
44
+
45
+ double nextDouble ()
46
+ {
47
+ return Double .parseDouble (next ());
48
+ }
49
+
50
+ String nextLine ()
51
+ {
52
+ String str = "" ;
53
+ try
54
+ {
55
+ str = br .readLine ();
56
+ }
57
+ catch (IOException e )
58
+ {
59
+ e .printStackTrace ();
60
+ }
61
+ return str ;
62
+ }
63
+ }
64
+ public static void main (String [] args ) throws java .lang .Exception {
65
+ FastReader sc =new FastReader ();
66
+ int t =sc .nextInt ();
67
+ while (t -->0 ) {
68
+ int n =sc .nextInt ();
69
+ long w =sc .nextLong ();
70
+ long wr =sc .nextLong ();
71
+ long [] wt =new long [n ];
72
+ Hashtable <Long ,Long > d = new Hashtable <>();
73
+ long temp ;
74
+ for (int i =0 ;i <n ;i ++) {
75
+ wt [i ]=sc .nextLong ();
76
+ if (d .get (wt [i ])==null ) {
77
+ d .put (wt [i ],(long ) 1 );
78
+ }
79
+ else {
80
+ temp =(long ) d .get (wt [i ]);
81
+ d .put (wt [i ],temp +1 );
82
+ }
83
+ }
84
+ long temp2 ,resw =0 ;
85
+ for (Enumeration k =d .keys (),ele =d .elements ();k .hasMoreElements ();)
86
+ {
87
+ temp =(long ) k .nextElement ();
88
+ temp2 =(long ) ele .nextElement ();
89
+ if (temp2 >=2 ) {
90
+ if (temp2 %2 ==0 ) {
91
+ resw =resw +temp *temp2 ;
92
+ }
93
+ else {
94
+ resw =resw +temp *(temp2 -1 );
95
+ }
96
+ }
97
+ }
98
+ if (resw +wr >=w ) {
99
+ System .out .print ("YES\n " );
100
+ }
101
+ else {
102
+ System .out .print ("NO\n " );
103
+ }
104
+ }
105
+ }
106
+ }
You can’t perform that action at this time.
0 commit comments