#include <iostream> #include <algorithm> using namespace std; int T(int a, int b) { return a * b; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k, a, curr_min=2019; cin>>n>>k; for(int row = 1; row <= n; ++row) { for (int col = 1; col <= row; ++col) { cin>>a; if (T(row-col+1, col) <= k) curr_min = min(curr_min, a); } } cout<<curr_min<<endl; 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 | #include <iostream> #include <algorithm> using namespace std; int T(int a, int b) { return a * b; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k, a, curr_min=2019; cin>>n>>k; for(int row = 1; row <= n; ++row) { for (int col = 1; col <= row; ++col) { cin>>a; if (T(row-col+1, col) <= k) curr_min = min(curr_min, a); } } cout<<curr_min<<endl; return 0; } |