fork download
  1. public class TrySail {
  2.  
  3. static int n;
  4. static int all;
  5. static int arr[];
  6. static int DP[][][][] = new int[51][260][260][12];
  7. // {178, 111, 60, 202, 194, 170, 118, 170, 99, 119, 142, 242, 229, 70, 243, 238, 74, 7}
  8. static boolean getBit(int num, int idx) {
  9. return ( ((num >> idx) & 1) == 1);
  10.  
  11. }
  12.  
  13. static int setBit(int num,int idx){
  14.  
  15. return num|((1<<idx));
  16.  
  17. }
  18. static int solve(int idx,int s1,int s2,int msk)
  19. {
  20. if(idx == n)
  21. {
  22. if(getBit(msk,0) && getBit(msk,1) && getBit(msk,2)) return (all^s1^s2) + s1 + s2;
  23. else return -50;
  24. }
  25. if(DP[idx][s1][s2][msk] != -1) return DP[idx][s1][s2][msk];
  26. int ret = 0;
  27. ret = Math.max(ret,solve(idx+1,s1,s2,setBit(msk,2)));
  28. ret = Math.max(ret,solve(idx+1,s1^arr[idx],s2,setBit(msk,0)));
  29. ret = Math.max(ret,solve(idx+1,s1,s2^arr[idx],setBit(msk,1)));
  30.  
  31. return DP[idx][s1][s2][msk] = ret;
  32.  
  33. }
  34.  
  35.  
  36.  
  37. public static int get(int[] strength)
  38. {
  39. arr = strength;
  40. n = arr.length;
  41. all = 0;
  42. for(int i = 0 ;i < arr.length ; i++) all ^= arr[i];
  43. for(int i = 0 ; i < 51 ; i++)
  44. {
  45. for(int j = 0 ; j < 260 ; j++)
  46. {
  47. for(int k = 0 ; k < 260 ; k++)
  48. {
  49. for(int f = 0 ; f < 12; f++)
  50. DP[i][j][k][f] = -1;
  51. }
  52. }
  53. }
  54.  
  55. return solve(0,0,0,0);
  56. }
  57.  
  58. public static void main(String[]args)throws Throwable
  59. {
  60.  
  61.  
  62. }
  63.  
  64.  
  65. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class TrySail is public, should be declared in a file named TrySail.java
public class TrySail {
       ^
1 error
stdout
Standard output is empty