fork download
  1. public class ThreeIncreasing {
  2. public int minEaten(int a, int b, int c) {
  3. int b_change = max(0, b - (c - 1)); // decrease b to c-1
  4. b -= b_change;
  5. int a_change = max(0, a - (b - 1)); // decrease a to b-1
  6. a -= a_change;
  7. if(a <= 0)
  8. return -1;
  9. return a_change + b_change;
  10. }
  11. }
  12.  
  13.  
  14.  
  15. public class SellingFruits {
  16. public int maxDays(int x, int f, int d, int p) {
  17. int low = 0, high = d;
  18. while(low < high) {
  19. int days = (int) (((long) low + high + 1) / 2);
  20. long needMoney = (long) days * x + (long) p * max(0, days - f);
  21. if(needMoney <= d)
  22. low = days;
  23. else
  24. high = days - 1;
  25. }
  26. return low;
  27. }
  28. }
  29.  
  30.  
  31.  
  32. public class MappingABC2 {
  33. public int countStrings(int[] t) {
  34. final int MOD = 1000 * 1000 * 1000 + 7;
  35. int n = t.length;
  36. int MAX_VAL = 0;
  37. for(int i = 0; i < n; ++i) {
  38. MAX_VAL = max(MAX_VAL, t[i]);
  39. --t[i];
  40. }
  41. boolean appears[] = new boolean[MAX_VAL];
  42. for(int i = 0; i < MAX_VAL; ++i)
  43. appears[i] = false;
  44. for(int x : t)
  45. appears[x] = true;
  46. int answer = 0;
  47. for(int a0 = 0; a0 < n; ++a0)
  48. for(int b0 = a0 + 1; b0 < n; ++b0)
  49. for(int c0 = b0 + 1; c0 < n; ++c0) {
  50. boolean a[] = new boolean[MAX_VAL];
  51. boolean b[] = new boolean[MAX_VAL];
  52. boolean c[] = new boolean[MAX_VAL];
  53. for(int x = 0; x < MAX_VAL; ++x)
  54. a[x] = b[x] = c[x] = true;
  55. for(int i = 0; i < a0; ++i)
  56. a[t[i]] = false; // no 'A'
  57. b[t[a0]] = c[t[a0]] = false; // first 'A'
  58. for(int i = a0 + 1; i < b0; ++i)
  59. b[t[i]] = false; // no 'B'
  60. a[t[b0]] = c[t[b0]] = false; // first 'B'
  61. for(int i = b0 + 1; i < c0; ++i)
  62. c[t[i]] = false; // no 'C'
  63. a[t[c0]] = b[t[c0]] = false; // first 'C'
  64. int product = 1;
  65. for(int i = 0; i < MAX_VAL; ++i) if(appears[i]) {
  66. int ways = (a[i]?1:0) + (b[i]?1:0) + (c[i]?1:0);
  67. product = (int) ((long) product * ways % MOD);
  68. }
  69. answer = (answer + product) % MOD;
  70. }
  71. return answer;
  72. }
  73. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class ThreeIncreasing is public, should be declared in a file named ThreeIncreasing.java
public class ThreeIncreasing {
       ^
Main.java:15: error: class SellingFruits is public, should be declared in a file named SellingFruits.java
public class SellingFruits {
       ^
Main.java:32: error: class MappingABC2 is public, should be declared in a file named MappingABC2.java
public class MappingABC2 {
       ^
Main.java:3: error: cannot find symbol
		int b_change = max(0, b - (c - 1)); // decrease b to c-1
		               ^
  symbol:   method max(int,int)
  location: class ThreeIncreasing
Main.java:5: error: cannot find symbol
		int a_change = max(0, a - (b - 1)); // decrease a to b-1
		               ^
  symbol:   method max(int,int)
  location: class ThreeIncreasing
Main.java:20: error: cannot find symbol
			long needMoney = (long) days * x + (long) p * max(0, days - f);
			                                              ^
  symbol:   method max(int,int)
  location: class SellingFruits
Main.java:38: error: cannot find symbol
			MAX_VAL = max(MAX_VAL, t[i]);
			          ^
  symbol:   method max(int,int)
  location: class MappingABC2
7 errors
stdout
Standard output is empty