fork download
  1. class Solution {
  2.  
  3. public static List<Integer> getUnfulfilledCustomers(List<List<Integer>> requests, long totalInventory) {
  4. int n = requests.size();
  5. long[][] arr = new long[n][5];
  6.  
  7. for (int i = 0; i < n; i++) {
  8. List<Integer> r = requests.get(i);
  9. arr[i][0] = r.get(0);
  10. arr[i][1] = r.get(1);
  11. arr[i][2] = r.get(2);
  12. arr[i][3] = r.get(3);
  13. arr[i][4] = r.get(1);
  14. }
  15.  
  16. Arrays.sort(arr, (a, b) -> {
  17. if (a[2] != b[2]) {
  18. return (int) (b[2] - a[2]);
  19. }
  20. return (int) (a[3] - b[3]);
  21. });
  22.  
  23. long remainingStock = totalInventory;
  24.  
  25. for (int i = 0; i < n; i++) {
  26. if (remainingStock <= 0) {
  27. break;
  28. }
  29.  
  30. int sameBidCount = 0;
  31. for (int j = i; j < n; j++) {
  32. if (arr[j][2] == arr[i][2]) {
  33. sameBidCount++;
  34. } else {
  35. break;
  36. }
  37. }
  38.  
  39. if (remainingStock < sameBidCount) {
  40. for (int j = 0; j < remainingStock; j++) {
  41. arr[i + j][1]--;
  42. }
  43. remainingStock = 0;
  44. break;
  45. }
  46.  
  47. remainingStock -= arr[i][1];
  48. arr[i][1] = 0;
  49. }
  50.  
  51. List<Integer> unfulfilled = new ArrayList<>();
  52. for (int i = 0; i < n; i++) {
  53. if (arr[i][1] == arr[i][4]) {
  54. unfulfilled.add((int) arr[i][0]);
  55. }
  56. }
  57.  
  58. Collections.sort(unfulfilled);
  59. return unfulfilled;
  60. }
  61. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: error: cannot find symbol
    public static List<Integer> getUnfulfilledCustomers(List<List<Integer>> requests, long totalInventory) {
                                                        ^
  symbol:   class List
  location: class Solution
Main.java:3: error: cannot find symbol
    public static List<Integer> getUnfulfilledCustomers(List<List<Integer>> requests, long totalInventory) {
                                                             ^
  symbol:   class List
  location: class Solution
Main.java:3: error: cannot find symbol
    public static List<Integer> getUnfulfilledCustomers(List<List<Integer>> requests, long totalInventory) {
                  ^
  symbol:   class List
  location: class Solution
Main.java:8: error: cannot find symbol
            List<Integer> r = requests.get(i);
            ^
  symbol:   class List
  location: class Solution
Main.java:16: error: cannot find symbol
        Arrays.sort(arr, (a, b) -> {
        ^
  symbol:   variable Arrays
  location: class Solution
Main.java:51: error: cannot find symbol
        List<Integer> unfulfilled = new ArrayList<>();
        ^
  symbol:   class List
  location: class Solution
Main.java:51: error: cannot find symbol
        List<Integer> unfulfilled = new ArrayList<>();
                                        ^
  symbol:   class ArrayList
  location: class Solution
Main.java:58: error: cannot find symbol
        Collections.sort(unfulfilled);
        ^
  symbol:   variable Collections
  location: class Solution
8 errors
stdout
Standard output is empty