#include <stdio.h> #include <stdlib.h> #define MAXN 2048 #define MAXNN (MAXN*MAXN) int ia = 0; int a[MAXNN]; int main() { int n, k, m; scanf("%d%d", &n, &k); for (int i=1;i<=n;i++) { for (int j=1;j<=i;j++) { scanf("%d", &a[ia]); ia++; } } m = 2019; for (int i=0;i<n;i++) { for (int j=0;j<=i;j++) { if ((j+1)*(i-j+1)<=k && m>a[j+(i+1)*i/2]) m = a[j+(i+1)*i/2]; // printf("%d ", a[j+(i+1)*i/2]); //printf("%dx%d ", j+1, i-j+1); } //printf("\n"); } 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 31 | #include <stdio.h> #include <stdlib.h> #define MAXN 2048 #define MAXNN (MAXN*MAXN) int ia = 0; int a[MAXNN]; int main() { int n, k, m; scanf("%d%d", &n, &k); for (int i=1;i<=n;i++) { for (int j=1;j<=i;j++) { scanf("%d", &a[ia]); ia++; } } m = 2019; for (int i=0;i<n;i++) { for (int j=0;j<=i;j++) { if ((j+1)*(i-j+1)<=k && m>a[j+(i+1)*i/2]) m = a[j+(i+1)*i/2]; // printf("%d ", a[j+(i+1)*i/2]); //printf("%dx%d ", j+1, i-j+1); } //printf("\n"); } printf("%d\n", m); return 0; } |