#include <iostream> using namespace std; int main(){ int n, k, w, wm=2019; scanf("%d %d", &n, &k); for (int p=1; p<=n; p++){ for (int d=1; d<=p; d++){ scanf("%d", &w); if ((w<wm)&&(((p-d+1)*d)<=k)) wm=w; } } printf("%d", wm); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include <iostream> using namespace std; int main(){ int n, k, w, wm=2019; scanf("%d %d", &n, &k); for (int p=1; p<=n; p++){ for (int d=1; d<=p; d++){ scanf("%d", &w); if ((w<wm)&&(((p-d+1)*d)<=k)) wm=w; } } printf("%d", wm); return 0; } |