Example #1
1
  public static void main(String[] args) throws IOException {
    long T, N, K, N_temp, a;
    Reader.init(System.in);
    T = Reader.nextLong();
    while (T-- > 0) {
      N = Reader.nextLong();
      K = Reader.nextLong();

      /*N_temp=N;
      while(N_temp-->0)
      	a=Reader.nextLong();*/

      System.out.println(sumbincoef(N - 1, K));
    }
  }
Example #2
1
  public static void main(String[] args) throws IOException {
    in = new Reader();
    out = new PrintWriter(System.out, true);

    int N = in.nextInt();

    PriorityQueue<Long> pq = new PriorityQueue<Long>();
    for (int i = 0; i < N; i++) pq.add(in.nextLong());

    long cost = 0;
    while (pq.size() > 1) {
      long a = pq.poll() + pq.poll();
      cost += a;
      pq.add(a);
    }

    out.println(cost);
  }