DdoubleJ
2018. 6. 28. 17:02
2018. 6. 28. 17:02
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include <stdio.h> #include <algorithm> using namespace std; int main(void) { setbuf(stdout, NULL); int test_case; scanf("%d", &test_case); for (int z = 1; z<= test_case; z++) { int n, m, k; scanf("%d%d%d", &n,&m,&k); int a[101] = { 0, }; for (int i = 0; i < 101; i++) a[i] = 2e9; for(int i=0;i<n;i++) scanf("%d", &a[i]); sort(a, a + 100); int cnt = 0; printf("#%d ", z); if (a[0] < m) { printf("Impossible\n"); continue; } int check = 0; for (int i = 0, j = 0; j < n; i = i + 1) { if (i != 0 && i%m == 0) cnt += k; for (; a[j] <= i;) { cnt--; j++; } if (cnt < 0) { check = -1; break; } } if (check == -1) printf("Impossible\n"); else printf("Possible\n"); } return 0; } | cs |