#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vi = vector<int>;
using Pii = pair<int, int>;
using Pli = pair<ll, int>;
#define pb push_back
#define rep(i,b,e) for(int i=(b); i<(e); i++)
#define each(a,x) for(auto& a : (x))
#define all(x) (x).begin(),(x).end()
#define sz(x) int((x).size())
#define endl "\n"
#define x first
#define y second
const int inf = 1e9 + 10;
const ll mod = 1e9 + 7;
void solve() {
int n, k;
cin >> n >> k;
int res = 3000;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
int x;
cin >> x;
if (j * (i-j + 1) <= k) res = min(res, x);
}
}
cout << res << endl;
}
int main() {
cin.sync_with_stdio(0); cin.tie(0);
cout << fixed << setprecision(18);
solve();
return 0;
}
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 | #include <bits/stdc++.h> using namespace std; using ll = long long; using Vi = vector<int>; using Pii = pair<int, int>; using Pli = pair<ll, int>; #define pb push_back #define rep(i,b,e) for(int i=(b); i<(e); i++) #define each(a,x) for(auto& a : (x)) #define all(x) (x).begin(),(x).end() #define sz(x) int((x).size()) #define endl "\n" #define x first #define y second const int inf = 1e9 + 10; const ll mod = 1e9 + 7; void solve() { int n, k; cin >> n >> k; int res = 3000; for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { int x; cin >> x; if (j * (i-j + 1) <= k) res = min(res, x); } } cout << res << endl; } int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(18); solve(); return 0; } |
English