public void solve() throws IOException {
    double maxprofit = 0;
    double min = Double.MAX_VALUE;
    int mintime = -1;
    int buytime = -1;
    int selltime = -1;
    String input = "";
    int time = 0;
    while ((input = nextLine()) != null && input.length() > 0) {
      double price = Double.parseDouble(input);
      if (price < min) {
        min = price;
        mintime = time;
      }
      if (price - min > maxprofit) {
        buytime = mintime;
        selltime = time;
        maxprofit = price - min;
      }
      time++;
    }
    if (maxprofit > 0) {
      System.out.format("Buy: %d%nSell: %d%n", buytime, selltime);
    } else {
      System.out.println("No Profit");
    }
  }