#include<bits/stdc++.h> using namespace std; int main(){ int n,k,i,j,y,result; scanf("%d%d",&n,&k); result=2019; for(j=1;j<=n;j++) for(i=1;i<=j;i++){ scanf("%d",&y); if(i*(j-i+1)<=k) result=min(result,y); } printf("%d",result); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include<bits/stdc++.h> using namespace std; int main(){ int n,k,i,j,y,result; scanf("%d%d",&n,&k); result=2019; for(j=1;j<=n;j++) for(i=1;i<=j;i++){ scanf("%d",&y); if(i*(j-i+1)<=k) result=min(result,y); } printf("%d",result); return 0; } |