#include<bits/stdc++.h> using namespace std; int main(){ int n, k; cin >> n >> k; int ans = 2020; for(int y = 1; y <= n; y++){ for(int x = 1; x <= y; x++){ int p, q; cin >> p; q = x * (y - x + 1) - 1; if(q <= k && p < ans)ans = p; } } cout << ans; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include<bits/stdc++.h> using namespace std; int main(){ int n, k; cin >> n >> k; int ans = 2020; for(int y = 1; y <= n; y++){ for(int x = 1; x <= y; x++){ int p, q; cin >> p; q = x * (y - x + 1) - 1; if(q <= k && p < ans)ans = p; } } cout << ans; } |