//Author: Piotr Zielinski #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> PII; const int N = 2e3+5; int multiTable[N][N]; //A003991 int solve(int n, int k) { int x, res=2e9; for(int i = 1;i <= n;++i) { for(int j = 1;j <= i;++j) { multiTable[i][j] = (i-j+1)*j; cin >> x; if(multiTable[i][j] <= k) res = min(res, x); } } return res; } int main() { ios::sync_with_stdio(0); int n, k; cin >> n >> k; cout << solve(n, k) << "\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 | //Author: Piotr Zielinski #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> PII; const int N = 2e3+5; int multiTable[N][N]; //A003991 int solve(int n, int k) { int x, res=2e9; for(int i = 1;i <= n;++i) { for(int j = 1;j <= i;++j) { multiTable[i][j] = (i-j+1)*j; cin >> x; if(multiTable[i][j] <= k) res = min(res, x); } } return res; } int main() { ios::sync_with_stdio(0); int n, k; cin >> n >> k; cout << solve(n, k) << "\n"; return 0; } |