#include <stdio.h> int f(int n,int k) { if (2*k>n+1) k=n+1-k; return k*(n+1-k); } int main() { int U,NN,n,k,mini,a; mini=2020; scanf("%d %d",&NN,&U); for(n=1;n<=NN;++n) for(k=1;k<=n;++k) { scanf("%d",&a); if(a<=mini && f(n,k)<=U) mini=a; } printf("%d\n",mini); 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 | #include <stdio.h> int f(int n,int k) { if (2*k>n+1) k=n+1-k; return k*(n+1-k); } int main() { int U,NN,n,k,mini,a; mini=2020; scanf("%d %d",&NN,&U); for(n=1;n<=NN;++n) for(k=1;k<=n;++k) { scanf("%d",&a); if(a<=mini && f(n,k)<=U) mini=a; } printf("%d\n",mini); return 0; } |