#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int maxn = 2005;
int ile[maxn][maxn];
int main()
{
ios_base::sync_with_stdio(0);
int n, k;
while(cin >> n >> k)
{
for(int i = 0; i < n; i++)
{
for(int j = 0; j < (n - i); j++)
{
int prod = (i + 1) * (j + 1);
ile[i + j][i] = prod;
}
}
int res = 3000;
for(int i = 0; i < n; i++)
{
for(int j = 0; j <= i; j++)
{
int a;
cin >> a;
if(ile[i][j] <= k)
res = min(res, a);
}
}
cout << res << "\n";
}
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 40 41 42 43 44 | #include <bits/stdc++.h> #define fi first #define se second using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; const int maxn = 2005; int ile[maxn][maxn]; int main() { ios_base::sync_with_stdio(0); int n, k; while(cin >> n >> k) { for(int i = 0; i < n; i++) { for(int j = 0; j < (n - i); j++) { int prod = (i + 1) * (j + 1); ile[i + j][i] = prod; } } int res = 3000; for(int i = 0; i < n; i++) { for(int j = 0; j <= i; j++) { int a; cin >> a; if(ile[i][j] <= k) res = min(res, a); } } cout << res << "\n"; } return 0; } |
English