Submission #3423843
Source Code Expand
import java.util.*; class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int d = sc.nextInt(); long G = sc.nextLong() / 100; int[] p = new int[d], g = new int[d], max = new int[d]; int k = (int)Math.pow(2, d); for(int i = 0; i < d; i++){ p[i] = sc.nextInt(); g[i] = sc.nextInt() / 100; max[i] = (i + 1) * p[i] + g[i]; } int ans = Integer.MAX_VALUE; for(int i = 0; i < k; i++){ long gg = G; String kk = to2(i, d); int tmp = 0; int min = -1; for(int j = 0; j < d; j++){ if(kk.charAt(j) == '1'){ gg -= max[j]; tmp += p[j]; }else{ min = j; } } if(min >= 0 && 0 <= gg && gg < max[min]){ tmp += Math.min(gg / (min + 1), p[min] - 1); } System.out.println(kk + " " + tmp); ans = Math.min(ans, tmp); } System.out.println(ans); } static String to2 (int m, int d){ String ans = ""; for(int i = 0; i < d; i++){ if(m % 2 == 0){ m /= 2; ans = "0" + ans; } else{ m--; m /= 2; ans = "1" + ans; } } return ans; } }
Submission Info
Submission Time | |
---|---|
Task | C - All Green |
User | tonq |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1536 Byte |
Status | WA |
Exec Time | 149 ms |
Memory | 25044 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | a01, a02, a03, a04 |
All | a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
a01 | WA | 93 ms | 20564 KB |
a02 | WA | 92 ms | 18768 KB |
a03 | WA | 94 ms | 21844 KB |
a04 | WA | 92 ms | 19796 KB |
b05 | WA | 94 ms | 22868 KB |
b06 | WA | 140 ms | 23636 KB |
b07 | WA | 141 ms | 22996 KB |
b08 | WA | 93 ms | 21076 KB |
b09 | WA | 91 ms | 19796 KB |
b10 | WA | 94 ms | 20692 KB |
b11 | WA | 95 ms | 23764 KB |
b12 | WA | 117 ms | 21844 KB |
b13 | WA | 118 ms | 24276 KB |
b14 | WA | 142 ms | 22740 KB |
b15 | WA | 143 ms | 25044 KB |
b16 | WA | 143 ms | 23636 KB |
b17 | WA | 140 ms | 23636 KB |
b18 | WA | 132 ms | 24148 KB |
b19 | WA | 134 ms | 23124 KB |
b20 | WA | 118 ms | 23380 KB |
b21 | WA | 121 ms | 19156 KB |
b22 | WA | 142 ms | 24016 KB |
b23 | WA | 139 ms | 24660 KB |
b24 | WA | 149 ms | 24788 KB |