#include <bits/stdc++.h> using namespace std; int main() { int n; long long k; cin >> n >> k; int global_min = INT_MAX; for (int x = 1; x <= n; x++) { for (int y = 1; y <= x; y++) { int year; cin >> year; if (((long long) (x - y + 1)) * y <= k) { global_min = min(global_min, year); } } } cout << global_min << "\n"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <bits/stdc++.h> using namespace std; int main() { int n; long long k; cin >> n >> k; int global_min = INT_MAX; for (int x = 1; x <= n; x++) { for (int y = 1; y <= x; y++) { int year; cin >> year; if (((long long) (x - y + 1)) * y <= k) { global_min = min(global_min, year); } } } cout << global_min << "\n"; } |