#include <cstdio> int main(void) { int n, k, l, c, y, kx, ks, a; a = 2020; scanf("%d%d", &n, &k); for (l = 1; l <= n; l++) { kx = l; ks = l; for (c = 0; c < l; c++) { scanf("%d", &y); if (kx <= k && y < a) a = y; ks -= 2; kx += ks; } } printf("%d\n", a); return 0; }
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 | #include <cstdio> int main(void) { int n, k, l, c, y, kx, ks, a; a = 2020; scanf("%d%d", &n, &k); for (l = 1; l <= n; l++) { kx = l; ks = l; for (c = 0; c < l; c++) { scanf("%d", &y); if (kx <= k && y < a) a = y; ks -= 2; kx += ks; } } printf("%d\n", a); return 0; } |