#include <cstdio> #include <algorithm> using namespace std; const int MAXN = 2e3 + 23; int main() { int n, k; int x, a, b; int wyn = 2023; scanf("%d %d", &n, &k); for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { scanf("%d", &x); a = j - 1; b = i - j; a = i * (i + 1) / 2 - (a * (a + 1) / 2 + b * (b + 1) / 2); if (a <= k) wyn = min(wyn, x); } } printf("%d", wyn); 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 | #include <cstdio> #include <algorithm> using namespace std; const int MAXN = 2e3 + 23; int main() { int n, k; int x, a, b; int wyn = 2023; scanf("%d %d", &n, &k); for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { scanf("%d", &x); a = j - 1; b = i - j; a = i * (i + 1) / 2 - (a * (a + 1) / 2 + b * (b + 1) / 2); if (a <= k) wyn = min(wyn, x); } } printf("%d", wyn); return 0; } |