#include <cstdio> int main(){ int i=1,j=1,diag=1; int n,k,ni,min,el; scanf("%d",&n); scanf("%d",&k); min = 2020; for(ni=0;ni<(n*(n+1))/2;ni++){ scanf("%d",&el); // printf("%d, %d\n",i*j,min); if(i*j<=k){ if(el<min) min=el; } if(i==1){ i = j+1; j = 1; } else{ i--; j++; } } printf("%d",min); }
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 | #include <cstdio> int main(){ int i=1,j=1,diag=1; int n,k,ni,min,el; scanf("%d",&n); scanf("%d",&k); min = 2020; for(ni=0;ni<(n*(n+1))/2;ni++){ scanf("%d",&el); // printf("%d, %d\n",i*j,min); if(i*j<=k){ if(el<min) min=el; } if(i==1){ i = j+1; j = 1; } else{ i--; j++; } } printf("%d",min); } |