#include <iostream> #include <vector> using namespace std; using ULL = unsigned long long; const int MAX_R = 2019; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); vector<vector<int>> v; int n, k, r; cin >> n >> k; for (int i = 1; i <= n; i++) { v.push_back(vector<int>()); for (int j = 1; j <= i; j++) { cin >> r; v[i-1].push_back(r); } } int minr = MAX_R; for (int i = 1; i <= n; i++) { if (i > k) break; for (int j = 1; j <= i; j++) { if (j * (i - j + 1) > k) break; minr = min(minr, min(v[i-1][j-1], v[i-1][i-j])); } } cout << minr << '\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 | #include <iostream> #include <vector> using namespace std; using ULL = unsigned long long; const int MAX_R = 2019; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); vector<vector<int>> v; int n, k, r; cin >> n >> k; for (int i = 1; i <= n; i++) { v.push_back(vector<int>()); for (int j = 1; j <= i; j++) { cin >> r; v[i-1].push_back(r); } } int minr = MAX_R; for (int i = 1; i <= n; i++) { if (i > k) break; for (int j = 1; j <= i; j++) { if (j * (i - j + 1) > k) break; minr = min(minr, min(v[i-1][j-1], v[i-1][i-j])); } } cout << minr << '\n'; return 0; } |