#include <iostream> #include <vector> #include <cstdlib> #include <algorithm> using namespace std; int main () { int wiersze, butelki; cin >> wiersze >> butelki; vector<int> T; for (int i=1;i<=wiersze;i++) { for (int j = 1;j<=i;j++) { int x; cin >> x; if ((i - j + 1) * j <= butelki)T.push_back(x); } } cout << *min_element(T.begin(), T.end()); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <iostream> #include <vector> #include <cstdlib> #include <algorithm> using namespace std; int main () { int wiersze, butelki; cin >> wiersze >> butelki; vector<int> T; for (int i=1;i<=wiersze;i++) { for (int j = 1;j<=i;j++) { int x; cin >> x; if ((i - j + 1) * j <= butelki)T.push_back(x); } } cout << *min_element(T.begin(), T.end()); } |