#include <iostream> using namespace std; const int MAX_A = 2020; int main() { ios_base::sync_with_stdio(false); int n, k, x, best = MAX_A; cin >> n >> k; for(int r = 0; r < n; ++r) { for(int c = 0; c <= r; ++c) { cin >> x; if((c + 1) * (r - c + 1) <= k && x < best) best = x; } } cout << best << endl; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <iostream> using namespace std; const int MAX_A = 2020; int main() { ios_base::sync_with_stdio(false); int n, k, x, best = MAX_A; cin >> n >> k; for(int r = 0; r < n; ++r) { for(int c = 0; c <= r; ++c) { cin >> x; if((c + 1) * (r - c + 1) <= k && x < best) best = x; } } cout << best << endl; return 0; } |