fork download
  1.  
  2. package Interview_Questions;
  3. import java.util.*;
  4.  
  5. public class microsoft_1 {
  6. static void main() {
  7. Scanner sc = new Scanner(System.in);
  8.  
  9. int n = sc.nextInt();
  10.  
  11. int[] req = new int[n];
  12. int[] stk = new int[n];
  13. int[] cos = new int[n];
  14.  
  15. for(int i=0; i<n; i++){
  16. req[i] = sc.nextInt();
  17. }
  18.  
  19. for(int i=0; i<n; i++){
  20. stk[i] = sc.nextInt();
  21. }
  22.  
  23. for(int i=0; i<n; i++){
  24. cos[i] = sc.nextInt();
  25. }
  26.  
  27. int bud = sc.nextInt();
  28.  
  29. long low = 0;
  30. long high = 1000000000L;
  31. long ans = 0;
  32.  
  33. while(low <= high){
  34.  
  35. long mid = low + (high-low)/2;
  36. long tcos = 0;
  37.  
  38. for(int i=0; i<n; i++){
  39. tcos += Math.max(0L,
  40. ((long)req[i]*mid-stk[i])*cos[i]);
  41. }
  42.  
  43. if(tcos > bud){
  44. high = mid-1;
  45. }
  46. else{
  47. ans = mid;
  48. low = mid+1;
  49. }
  50.  
  51. System.out.println(mid+" "+tcos);
  52. }
  53.  
  54. System.out.println(ans);
  55. }
  56. }
  57.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:5: error: class microsoft_1 is public, should be declared in a file named microsoft_1.java
public class microsoft_1 {
       ^
1 error
stdout
Standard output is empty