#include <stdio.h> #include <math.h> using namespace std; int main() { long result = 2020; long n = 0; long k = 0; long ai = 0; scanf("%ld", &n); scanf("%ld", &k); for (int i = 1; i <= n; i++) { for (int j = 0; j < i; j++) { scanf("%ld", &ai); if (ai < result) { int currK = (j + 1)*(i - j); if (currK < k) result = ai; } } } printf("%ld", result); 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 31 | #include <stdio.h> #include <math.h> using namespace std; int main() { long result = 2020; long n = 0; long k = 0; long ai = 0; scanf("%ld", &n); scanf("%ld", &k); for (int i = 1; i <= n; i++) { for (int j = 0; j < i; j++) { scanf("%ld", &ai); if (ai < result) { int currK = (j + 1)*(i - j); if (currK < k) result = ai; } } } printf("%ld", result); return 0; } |