#include <bits/stdc++.h> using namespace std; #define FOR(i, a, n) for(decltype(n) i = (a), i##__ = (n); i <= i##__; i++) #define REP(i, n) FOR(i, 0, (n)-1) #define FORD(i, a, n) for(decltype(a) i = (a), i##__ = (n); i >= i##__; i--) #define REPD(i, n) FORD(i, (n)-1, 0) #define V vector #define RS resize #define EB emplace_back #define ALL(X) X.begin(), X.end() #define SZ(X) int(X.size()) #define OS ostream #define ST first #define ND second constexpr char nl = '\n'; using VI = V<int>; using VVI = V<VI>; using II = pair<int, int>; using VII = V<II>; using L = long long; using VL = V<L>; #ifdef DEBUG # define D(a...) a #else # define D(a...) #endif # define I(a...) #a << ": " << a << nl template<class A, class B> OS& operator<<(OS &os, pair<A, B> &X) { return os << "(" << X.ST << ", " << X.ND << ")"; } template <class T> OS& operator<<(OS &os, V<T> &X){ os << "{"; REP(i, SZ(X)) os << X[i] << ((i == SZ(X) - 1) ? "" : ", "); return os << "}"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; int ans = 3000; FOR(i, 1, n) FOR(j, 1, i) { int x; cin >> x; if(j * (i - j + 1) <= k) ans = min(ans, x); } cout << ans << "\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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #include <bits/stdc++.h> using namespace std; #define FOR(i, a, n) for(decltype(n) i = (a), i##__ = (n); i <= i##__; i++) #define REP(i, n) FOR(i, 0, (n)-1) #define FORD(i, a, n) for(decltype(a) i = (a), i##__ = (n); i >= i##__; i--) #define REPD(i, n) FORD(i, (n)-1, 0) #define V vector #define RS resize #define EB emplace_back #define ALL(X) X.begin(), X.end() #define SZ(X) int(X.size()) #define OS ostream #define ST first #define ND second constexpr char nl = '\n'; using VI = V<int>; using VVI = V<VI>; using II = pair<int, int>; using VII = V<II>; using L = long long; using VL = V<L>; #ifdef DEBUG # define D(a...) a #else # define D(a...) #endif # define I(a...) #a << ": " << a << nl template<class A, class B> OS& operator<<(OS &os, pair<A, B> &X) { return os << "(" << X.ST << ", " << X.ND << ")"; } template <class T> OS& operator<<(OS &os, V<T> &X){ os << "{"; REP(i, SZ(X)) os << X[i] << ((i == SZ(X) - 1) ? "" : ", "); return os << "}"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; int ans = 3000; FOR(i, 1, n) FOR(j, 1, i) { int x; cin >> x; if(j * (i - j + 1) <= k) ans = min(ans, x); } cout << ans << "\n"; } |