Hello , please let me know for which test case it is falling
Solution: 46363012 | CodeChef
https://www.codechef.com/viewsolution/46363012
My Algorithm:-
1)Nodecount Map contains the number of nodes under this
2)x_at_node it contains x value at each node
3)once x_at_node table populated, suming all x’s mod of1000000007

On Mon, 3 May 2021, 19:34 sudeep.c...@gmail.com, <sudeep.chauha...@gmail.com>
wrote:

> Can someone please help me with what is wrong with my solution?
> The idea is to either pick a interval from start till the first smallest
> value (suppose if smallest is 3, then we can have win for 1 and 2 by
> picking 2), largest value to K (suppose if largest is 7 and k is 10, then
> we can have win for 8,9 and 10 by picking 8) as well as other possibilites
> which will be in between intervals (like [3, 7]--> pick 4, then win for
> 4,5).
>
> import java.io.BufferedReader;
> import java.io.IOException;
> import java.io.InputStreamReader;
> import java.io.PrintWriter;
> import java.util.ArrayList;
> import java.util.Arrays;
> import java.util.Collections;
> import java.util.List;
>
> public class Solution {
> public static void main(String[] args) throws IOException {
> BufferedReader br = new BufferedReader(
> new InputStreamReader(System.in));
> int t = Integer.parseInt(br.readLine());
> PrintWriter out = new PrintWriter(System.out);
> StringBuilder str = new StringBuilder("");
> for(int h=1;h<=t;h++)
> {
> str.append("Case #"+h+": ");
> String[] in = br.readLine().trim().split(" ");
> int n = Integer.parseInt(in[0]);
> long k = Long.parseLong(in[1]);
> long arr[] = new long[n];
> in = br.readLine().trim().split(" ");
> for(int i=0;i<n;i++){
> arr[i]=Long.parseLong(in[i]);
> }
> List<Long> diff = new ArrayList<>();
> Arrays.sort(arr);
> for(int i=1;i<arr.length;i++){
> long d = arr[i]-arr[i-1];
> if(d>0){
> d--;
> }
> diff.add(d);
> }
> Double p = new Double(0);
> Collections.sort(diff);
>
> List<Long> ans = new ArrayList<>();
> ans.add(k - arr[n-1]);
> ans.add(arr[0]-1);
> for(int j = diff.size()-1;j>=Math.max(0, diff.size()-2);j--){
> ans.add((diff.get(j)+1) / 2);
> }
> Collections.sort(ans);
> p += ans.get(ans.size()-1);
> p+=ans.get(ans.size()-2);
> str.append(p/(double)k+"\n");
> }
> out.print(str);
> out.flush();
> br.close();
> }
> }
>
> --
> -- You received this message because you are subscribed to the Google
> Groups Code Jam group. To post to this group, send email to
> google-code@googlegroups.com. To unsubscribe from this group, send email
> to google-code+unsubscr...@googlegroups.com. For more options, visit this
> group at https://groups.google.com/d/forum/google-code?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-code+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/cba4b486-e06a-4d73-9908-ca61677ae6e3n%40googlegroups.com
> <https://groups.google.com/d/msgid/google-code/cba4b486-e06a-4d73-9908-ca61677ae6e3n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
-- You received this message because you are subscribed to the Google Groups 
Code Jam group. To post to this group, send email to 
google-code@googlegroups.com. To unsubscribe from this group, send email to 
google-code+unsubscr...@googlegroups.com. For more options, visit this group at 
https://groups.google.com/d/forum/google-code?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAH5vfnMdXSSqcCysqhOmOfs0v8K%2BwNW3f9magVDXdqy-STAWew%40mail.gmail.com.

Reply via email to