fork download
  1. package BOJ;
  2.  
  3. import java.util.*;
  4.  
  5.  
  6. public class Main14501 {
  7.  
  8. public static int[] T;
  9. public static int[] P;
  10. public static int N = 0;
  11. public static int Max = 0;
  12.  
  13. public static void main(String[] args) {
  14.  
  15.  
  16.  
  17.  
  18. Scanner sc = new Scanner(System.in);
  19. N=sc.nextInt();
  20.  
  21. T= new int[N];
  22. P= new int[N];
  23.  
  24. for(int i=0 ; i< N ;i++) {
  25. T[i]=sc.nextInt();
  26. P[i]=sc.nextInt();
  27. }
  28.  
  29.  
  30. for(int i=0 ; i< N ;i++) {
  31. bru(i,0);
  32. }
  33.  
  34. System.out.println(Max);
  35.  
  36.  
  37. }
  38.  
  39. public static void bru(int now ,int sum) {
  40.  
  41.  
  42. sum+=P[now];
  43.  
  44. if(now+T[now] > N-1) {
  45. Max=Math.max(sum, Max);
  46. return;
  47.  
  48. }
  49.  
  50.  
  51.  
  52.  
  53. for(int i=now+T[now] ; i<N ;i++) {
  54. bru(i , sum);
  55.  
  56. }
  57. }
  58. }
  59.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:6: error: class Main14501 is public, should be declared in a file named Main14501.java
public class Main14501 {
       ^
1 error
stdout
Standard output is empty