#include<iostream> #define FOR(i, a, b) for(int i=(a); i <= (b); i++) using namespace std; typedef long long llint; int main(void) { int n, k; cin >> n >> k; int a, best; best = 2020; FOR(i, 1, n) { FOR(j, 1, i) { cin >> a; if ((i+1-j)*j <= k && a < best) best = a; } } cout << best << 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 | #include<iostream> #define FOR(i, a, b) for(int i=(a); i <= (b); i++) using namespace std; typedef long long llint; int main(void) { int n, k; cin >> n >> k; int a, best; best = 2020; FOR(i, 1, n) { FOR(j, 1, i) { cin >> a; if ((i+1-j)*j <= k && a < best) best = a; } } cout << best << endl; return 0; } |