#include <cstdio> #include <iostream> #include <algorithm> using namespace std; string c; int main(){ int n = 0; int k = 0; int best = 2020; int tmp = 2019; cin >> n; cin >> k; for(int i=0; i<n; ++i){ int j = 0; int q = i; while(j <= i){ cin >> tmp; if((q+1)*(j+1) <= k){ if(tmp < best){ best = tmp; } } j++; q--; } } cout << best << "\n"; 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 | #include <cstdio> #include <iostream> #include <algorithm> using namespace std; string c; int main(){ int n = 0; int k = 0; int best = 2020; int tmp = 2019; cin >> n; cin >> k; for(int i=0; i<n; ++i){ int j = 0; int q = i; while(j <= i){ cin >> tmp; if((q+1)*(j+1) <= k){ if(tmp < best){ best = tmp; } } j++; q--; } } cout << best << "\n"; return 0; } |