#include <cstdio> using namespace std; int min(int a, int b) { return a < b ? a : b; } int main() { int n, k, s; scanf("%d%d", &n, &k); s = n * (n + 1) / 2; int a, c = 1, l = 1, m = 2020; for (int i = 0; i < s; i++) { scanf("%d", &a); if ((l + 1 - c) * c <= k) { m = min(m, a); } if (c == l) { l++; c = 1; } else { c += 1; } } printf("%d\n", m); 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 | #include <cstdio> using namespace std; int min(int a, int b) { return a < b ? a : b; } int main() { int n, k, s; scanf("%d%d", &n, &k); s = n * (n + 1) / 2; int a, c = 1, l = 1, m = 2020; for (int i = 0; i < s; i++) { scanf("%d", &a); if ((l + 1 - c) * c <= k) { m = min(m, a); } if (c == l) { l++; c = 1; } else { c += 1; } } printf("%d\n", m); return 0; } |