#include <iostream> #include <cstdio> #include <cmath> using namespace std; int main() { int n, k; int result, time, a; scanf("%d %d", &n, &k); scanf("%d", &result); for(int i = 2; i<=n; i++) { for(int j = 1; j <= i; j++) { scanf("%d", &a); if(j == 1 || j == i) { time = i; } else { time = (i-1)*2 + 2*min(j-2, i-j-1); } //printf("(%d,%d) - %d", i, j, time); if(time <= k) { result = min(result, a); } } } printf("%d\n", result); return 0; } /* 1 2 2 3 4 3 4 6 6 4 5 8 10 8 5 6 10 12 12 10 6 */
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 32 33 34 35 36 37 38 39 40 41 42 43 | #include <iostream> #include <cstdio> #include <cmath> using namespace std; int main() { int n, k; int result, time, a; scanf("%d %d", &n, &k); scanf("%d", &result); for(int i = 2; i<=n; i++) { for(int j = 1; j <= i; j++) { scanf("%d", &a); if(j == 1 || j == i) { time = i; } else { time = (i-1)*2 + 2*min(j-2, i-j-1); } //printf("(%d,%d) - %d", i, j, time); if(time <= k) { result = min(result, a); } } } printf("%d\n", result); return 0; } /* 1 2 2 3 4 3 4 6 6 4 5 8 10 8 5 6 10 12 12 10 6 */ |