#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; int vintage, bottles_to_remove; int oldest_possible = 2019; for (int i = 0; i < n; i++) { for (int j = 0; j <= i; j++) { cin >> vintage; bottles_to_remove = (j + 1) * (i - j + 1); if (bottles_to_remove <= k && vintage < oldest_possible) { oldest_possible = vintage; } } } cout << oldest_possible << "\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 | #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; int vintage, bottles_to_remove; int oldest_possible = 2019; for (int i = 0; i < n; i++) { for (int j = 0; j <= i; j++) { cin >> vintage; bottles_to_remove = (j + 1) * (i - j + 1); if (bottles_to_remove <= k && vintage < oldest_possible) { oldest_possible = vintage; } } } cout << oldest_possible << "\n"; return 0; } |