#include <iostream> using namespace std; int n,m,a,wart,odp=25000; int wy; char ch; bool bb; int fastread () { wy=0; bb=false; ch=getchar(); if (ch=='-') { bb=true; ch=getchar(); } while (ch>='0'&&ch<='9') { wy*=10; wy+=int(ch)-48; ch=getchar(); } if (bb) return -wy; return wy; } int main() { n=fastread(); m=fastread(); for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { a=fastread(); wart=(i-j+1)*j; if(wart<=m&&a<odp) { odp=a; } } } cout<<odp; 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include <iostream> using namespace std; int n,m,a,wart,odp=25000; int wy; char ch; bool bb; int fastread () { wy=0; bb=false; ch=getchar(); if (ch=='-') { bb=true; ch=getchar(); } while (ch>='0'&&ch<='9') { wy*=10; wy+=int(ch)-48; ch=getchar(); } if (bb) return -wy; return wy; } int main() { n=fastread(); m=fastread(); for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { a=fastread(); wart=(i-j+1)*j; if(wart<=m&&a<odp) { odp=a; } } } cout<<odp; return 0; } |