import java.io.PrintStream; import java.util.Arrays; import java.util.Scanner; /** * Solution to Contest Construction * * @author vanb */ public class contest_vanb { /** Input. */ private static Scanner sc; /** Output. */ private static PrintStream ps; /** * Do it! */ private void doit() { int n = sc.nextInt(); int m = sc.nextInt(); // count[i][j][k] is the number of ways of putting together a problem set of size k+1 // where problem i and problem j are the two problems in the set with the highest ratings. long count[][][] = new long[n][n][m]; for( int i=0; i=ratings[k] ) ++count[j][k][2]; } // For problem sets of size 4+ for( int p=3; p0 ) for( int k=j+1; k=ratings[k] ) count[j][k][p] += count[i][j][p-1]; } } long total = 0L; for( int i=0; i