#include <iostream> using namespace std; int main() { int n, k, row = 1, col = 1, minYear = 2019, Year; cin >> n >> k; for (int i = 0; i < n * (n + 1) / 2; i++) { if (col > row) { row++; col = 1; } cin >> Year; if (col * (row - col + 1) <= k) if (Year < minYear) minYear = Year; col++; } cout << minYear; 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 | #include <iostream> using namespace std; int main() { int n, k, row = 1, col = 1, minYear = 2019, Year; cin >> n >> k; for (int i = 0; i < n * (n + 1) / 2; i++) { if (col > row) { row++; col = 1; } cin >> Year; if (col * (row - col + 1) <= k) if (Year < minYear) minYear = Year; col++; } cout << minYear; return 0; } |