#include <iostream> #include <limits> using namespace std; int main() { std::ios::sync_with_stdio(false); int n, k; int oldest = std::numeric_limits<int>::max(); cin >> n; cin >> k; for (int row = 1; row <= n; ++row) for (int b = 1; b <= row; ++b) { int year; cin >> year; int moves = b * (row - b + 1); if (moves > k) if (b == 1) { row = 100000; break; } else { continue; } oldest = std::min(year, oldest); } cout << oldest << "\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 | #include <iostream> #include <limits> using namespace std; int main() { std::ios::sync_with_stdio(false); int n, k; int oldest = std::numeric_limits<int>::max(); cin >> n; cin >> k; for (int row = 1; row <= n; ++row) for (int b = 1; b <= row; ++b) { int year; cin >> year; int moves = b * (row - b + 1); if (moves > k) if (b == 1) { row = 100000; break; } else { continue; } oldest = std::min(year, oldest); } cout << oldest << "\n"; return 0; } |