poj 1260 Java实现
import java.util.Scanner;
public class Main1260 {
static int Min(int a, int b) {
return a > b ? b : a;
}
public static void main(String[] args) throws Exception {
System.setIn(new java.io.FileInputStream("1260.txt"));
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for (int i = 0; i < T; i++) {
int C = sc.nextInt();
int Nu[] = new int[C+1];
int[] Pi = new int[C+1];
int dp[] = new int[C + 1];
int sum[]=new int[C+1];
for (int j = 1; j <= C; j++) {
Nu[j]=sc.nextInt();
sum[j]=sum[j-1]+Nu[j];
Pi[j]=sc.nextInt();
}
dp[0] = 0;
for (int j = 1; j <= C; j++) {
dp[j] = (Nu[j] + 10) * Pi[j] + dp[j - 1];
for (int j2 = 0; j2 < j; j2++) {
dp[j]=Min(dp[j], (sum[j]-sum[j2]+10)*Pi[j]+dp[j2]);
}
}
System.out.println(dp[C]);
}
}
}