#include <bits/stdc++.h> using namespace std; using ll = long long; int wololo(int n, int k) { return k * (n - k + 1); } int main() { int N, K; scanf("%d%d", &N, &K); int best = 1e9; for (int n = 1; n <= N; ++n) for (int x, k = 1; k <= n; ++k) { scanf("%d", &x); if (wololo(n, k) <= K) best = min(best, x); } printf("%d\n", best); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <bits/stdc++.h> using namespace std; using ll = long long; int wololo(int n, int k) { return k * (n - k + 1); } int main() { int N, K; scanf("%d%d", &N, &K); int best = 1e9; for (int n = 1; n <= N; ++n) for (int x, k = 1; k <= n; ++k) { scanf("%d", &x); if (wololo(n, k) <= K) best = min(best, x); } printf("%d\n", best); } |