Untitled
unknown
plain_text
a year ago
2.2 kB
3
Indexable
Never
package Nang_Cap_May_Tinh; import java.io.FileInputStream; import java.util.Scanner; public class nang_cap_may_tinh { static int n, m, l; static int [] giaTroi, Kim, visit; static int [][] sale; static int Ans; static void countSale(int i) { int count = 0; count += checkSale(i); for (int j = 0; j < n; j++) { if (visit[j+1] == -1) { visit[j+1] = 0; count += giaTroi[j]; } } if (Ans > count) Ans = count; } static int cnt_tmp; static int checkSale(int i) { boolean check = false; int cost = 0; for (int j = 2; j < sale[i][1] + 2; j++) { if (visit[sale[i][j]] == -1) { cnt_tmp++; visit[sale[i][j]] = 0; check = true; } } if (check) cost += sale[i][0]; return cost; } static void dfs(int x, int cost, int count) { for (int i = 0; i < m; i++) { if (i != x) { // if (checkSale(i)) } } if (count == l) { } } static void reset() { for (int i = 0; i < l; i++) { visit[Kim[i]] = -1; } } public static void main(String[] args) throws Exception{ System.setIn(new FileInputStream("D://Trainee//SRV_training//src//Nang_Cap_May_Tinh//may_tinh.txt")); Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for (int test_case = 1; test_case <= T; test_case++) { // input gia tung linh kien n = sc.nextInt(); giaTroi = new int[n]; visit = new int[n+1]; for (int i = 0; i < n; i++) { giaTroi[i] = sc.nextInt(); } // input cac goi sale m = sc.nextInt(); sale = new int [m][n+2]; for (int i = 0; i < m; i++) { // cot dau tien la gia cua goi sale sale[i][0] = sc.nextInt(); sale[i][1] = sc.nextInt(); for (int j = 2; j < sale[i][1] + 2; j++) { sale[i][j] = sc.nextInt(); } } // input cac linh kien Kim can mua l = sc.nextInt(); Kim = new int[l]; for (int i = 0; i < l; i++) { Kim[i] = sc.nextInt(); visit[Kim[i]] = -1; } Ans = 100000; cnt_tmp = 0; for (int i = 0; i < m; i++) { reset(); countSale(i); reset(); dfs(i, 0, 0); } System.out.println(); } } }