#include <cstdio> int main() { int n, k; scanf("%d%d", &n, &k); int m = 1, i = 1; int ans = 2019; while (m <= n) { int a; scanf("%d", &a); if (ans > a && i * (m - i + 1) <= k) ans = a; i++; if (i > m) { i = 1; m++; } } printf("%d\n", ans); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <cstdio> int main() { int n, k; scanf("%d%d", &n, &k); int m = 1, i = 1; int ans = 2019; while (m <= n) { int a; scanf("%d", &a); if (ans > a && i * (m - i + 1) <= k) ans = a; i++; if (i > m) { i = 1; m++; } } printf("%d\n", ans); } |