Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 99023

decrease compile time for complex algorithms by using more CPU [closed]

$
0
0

Executing a JAVA program is taking a lot of time. There is nothing wrong in large compile time as I was working on large data sets for competitive coding. Is there any way to fasten up my Java compile time. I am using VS Code to do so running on kUbuntu.Out of my 4 CPUs, only one shows 100%. Is there any way to use more resources aka hardware and fasten us my process by using other CPUs as well and giving more priority to VS Code than other software.

Here is the code if you need it, but you can skip it as it has nothing to do with the execution

import java.util.Scanner;
public class copy_hashcode {

    static int max=0;
    static int limit;
    static int pizza;
    static int abc[];//delete in future
    static int indexing[];
    //copy_hashcode obj=new copy_hashcode();
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int max_slices=sc.nextInt();
        limit=max_slices;
        indexing=new int[max_slices];
        //indexing=new int[max_slices];
        int type_of_pizzas=sc.nextInt();
        int arr[]=new int[type_of_pizzas];
        for (int i = 0; i < type_of_pizzas; i++) {
            arr[i]=sc.nextInt();
        }
        printCombination(arr,type_of_pizzas);
        System.out.println(pizza);
        for (int i = 0; i < pizza; i++) {
            System.out.print(indexing[i]+"");
        }
        sc.close();
    }

    static void printCombination(int arr[], int n_at_a_time) 
    { 
        for (int i = n_at_a_time; i > 0; i--) {
            int r=i;//make combinations taking r at a time
            int data[]=new int[r];
            int store_index[]=new int[r]; 
            combinationUtil(arr, data, 0, n_at_a_time-1, 0, r,store_index);
        }

    } 

    static void combinationUtil(int arr[], int data[], int start, 
                                int end, int index, int r,int store_index[]) 
    { 
        if (index == r) 
        { 
            int sum=0;
            for (int j=0; j<r; j++) {
                sum+=data[j]; 
            }
            if (sum<=limit && sum>=max) {// it all starts here
                pizza=r;
                int abb[]=new int[r];
                for (int i=0;i<r;i++) {
                    abb[i]=data[i];
                }

                for (int i=0;i<r;i++) {//storing index 
                    indexing[i]=store_index[i];

                }
                //indexing=store_index.clone();
                abc=abb;
                max=sum; 
            }
            return; 
        } 

        for (int i=start; i<=end && end-i+1 >= r-index; i++) 
        { 
            data[index] = arr[i];
            store_index[index]=i;
            combinationUtil(arr, data, i+1, end, index+1, r,store_index); 
        } 
    } 


}

Here is the input

4500 50 7 12 12 13 14 28 29 29 30 32 32 34 41 45 46 56 61 61 62 63 65 68 76 77 77 92 93 94 97 103 113 114 114 120 135 145 145 149 156 157 160 169 172 179 184 185 189 194 195 195


Viewing all articles
Browse latest Browse all 99023

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>