fork download
  1. package current;
  2.  
  3. import io.Reader;
  4. import io.OutputWriter;
  5.  
  6. public class ManageYourEnergy {
  7. long e,r;
  8. int n;
  9. public void solve(int testNumber, Reader in, OutputWriter out) {
  10. e = in.nextInt();
  11. r = in.nextInt();
  12. n = in.nextInt();
  13.  
  14. int[] v = in.nextIntArray(n);
  15.  
  16. out.println("Case #" + testNumber + ": " + solve(v, 0, n, e, 0));
  17. }
  18.  
  19. private long solve(int[] v, int from, int to, long startE, long toE) {
  20.  
  21. if(from == to)
  22. return 0;
  23.  
  24.  
  25. int index = from;
  26.  
  27. for(int i = from; i < to; ++i){
  28. if(v[i] > v[index])
  29. index = i;
  30. }
  31.  
  32. long startHere = Math.min(e, startE + (index - from) * r);
  33. long endHere = Math.max(0, toE - (to - index - 1) * r);
  34.  
  35. return solve(v, from, index, startE, Math.max(startHere - r, 0)) + (startHere - endHere) * 1L * v[index] + solve(v, index + 1, to, Math.min(e, r + endHere), toE);
  36.  
  37. }
  38. }
  39.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:6: error: class ManageYourEnergy is public, should be declared in a file named ManageYourEnergy.java
public class ManageYourEnergy {
       ^
Main.java:3: error: package io does not exist
import io.Reader;
         ^
Main.java:4: error: package io does not exist
import io.OutputWriter;
         ^
Main.java:9: error: cannot find symbol
    public void solve(int testNumber, Reader in, OutputWriter out) {
                                      ^
  symbol:   class Reader
  location: class ManageYourEnergy
Main.java:9: error: cannot find symbol
    public void solve(int testNumber, Reader in, OutputWriter out) {
                                                 ^
  symbol:   class OutputWriter
  location: class ManageYourEnergy
5 errors
stdout
Standard output is empty