#include <bits/stdc++.h> using namespace std; #define FOR(i,b,e) for(int i=(b);i<(int)(e);i++) #define REP(i,n) FOR(i,0,n) typedef long long ll; int main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k, a, best = 3000, above; cin >> n >> k; REP(i, n) REP(j, i + 1) { cin >> a; above = (j + 1) * (i - j + 1); if (above <= k && a < best) { best = a; } } cout << best << '\n'; }
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 | #include <bits/stdc++.h> using namespace std; #define FOR(i,b,e) for(int i=(b);i<(int)(e);i++) #define REP(i,n) FOR(i,0,n) typedef long long ll; int main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k, a, best = 3000, above; cin >> n >> k; REP(i, n) REP(j, i + 1) { cin >> a; above = (j + 1) * (i - j + 1); if (above <= k && a < best) { best = a; } } cout << best << '\n'; } |