#include <cstdio> typedef long long LL; int main() { LL N, K; scanf("%lld%lld", &N, &K); LL x = 0, y = 0, k = 0, rok = 0; LL mini = 3000; for (LL i = 0; i < N * (N + 1) / 2; ++i) { scanf("%lld", &rok); if ((x + 1) * (y + 1) <= K && rok < mini) mini = rok; ++x, --y; if (y < 0) x = 0, y = ++k; } printf("%lld\n", mini); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include <cstdio> typedef long long LL; int main() { LL N, K; scanf("%lld%lld", &N, &K); LL x = 0, y = 0, k = 0, rok = 0; LL mini = 3000; for (LL i = 0; i < N * (N + 1) / 2; ++i) { scanf("%lld", &rok); if ((x + 1) * (y + 1) <= K && rok < mini) mini = rok; ++x, --y; if (y < 0) x = 0, y = ++k; } printf("%lld\n", mini); } |