#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; int total = n * (n + 1) / 2; int row = 1, col = 1; int year, needed; int min_year = 9999; for (int i = 0; i < total; i++) { cin >> year; needed = col * (row - col + 1); if (needed <= k && year < min_year) { min_year = year; } if (col == row) { row++; col = 1; } else { col++; } } cout << min_year << "\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 | #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; int total = n * (n + 1) / 2; int row = 1, col = 1; int year, needed; int min_year = 9999; for (int i = 0; i < total; i++) { cin >> year; needed = col * (row - col + 1); if (needed <= k && year < min_year) { min_year = year; } if (col == row) { row++; col = 1; } else { col++; } } cout << min_year << "\n"; return 0; } |