#include <bits/stdc++.h>
using namespace std;
template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
auto n = load<int>();
auto k = load<int>();
auto best = numeric_limits<int>::max();
for (auto y=0; y<n; ++y)
for (auto x=0; x<y+1; ++x) {
auto wine = load<int>();
auto excavation = (y + 1 - x) * (x + 1);
if (excavation <= k)
best = min(best, wine);
}
cout << best << '\n';
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <bits/stdc++.h> using namespace std; template <typename T> T load() { T r; cin >> r; return r; } template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); auto n = load<int>(); auto k = load<int>(); auto best = numeric_limits<int>::max(); for (auto y=0; y<n; ++y) for (auto x=0; x<y+1; ++x) { auto wine = load<int>(); auto excavation = (y + 1 - x) * (x + 1); if (excavation <= k) best = min(best, wine); } cout << best << '\n'; } |
English