#include <cstdio> using namespace std; int minimal(int a, int b) { if (a < b) return a; else return b; } int getlinemin(int line_num, int k) { int loc_min = 2020; int rocznik; int under = line_num; for (int i = line_num - 2; i >= -line_num; i -= 2) { scanf("%d", &rocznik); if (under <= k && rocznik < loc_min) { loc_min = rocznik; under = under + i; } else { under = under + i; } } return loc_min; } int main() { int n; int k; scanf( "%d %d", &n, &k); int min = 2020; int mniej = minimal(n, k); for (int i = 1; i <= mniej; i++) { int minline = getlinemin(i, k); if (minline < min) { min = minline; } } printf("%d", min); 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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #include <cstdio> using namespace std; int minimal(int a, int b) { if (a < b) return a; else return b; } int getlinemin(int line_num, int k) { int loc_min = 2020; int rocznik; int under = line_num; for (int i = line_num - 2; i >= -line_num; i -= 2) { scanf("%d", &rocznik); if (under <= k && rocznik < loc_min) { loc_min = rocznik; under = under + i; } else { under = under + i; } } return loc_min; } int main() { int n; int k; scanf( "%d %d", &n, &k); int min = 2020; int mniej = minimal(n, k); for (int i = 1; i <= mniej; i++) { int minline = getlinemin(i, k); if (minline < min) { min = minline; } } printf("%d", min); return 0; } |