#include <iostream> using namespace std; typedef long long int lint; int main() { ios_base::sync_with_stdio(false); lint n, k; cin >> n >> k; int best = 1000000; for (lint r = 1; r <= n; ++r) { for (lint c = 1; c <= r; ++c) { int year; cin >> year; lint required = (r + 1 - c) * c; //cout << required << (c == r ? "\n" : " "); if (required <= k && year < best) { best = year; } } } cout << best << endl; 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 | #include <iostream> using namespace std; typedef long long int lint; int main() { ios_base::sync_with_stdio(false); lint n, k; cin >> n >> k; int best = 1000000; for (lint r = 1; r <= n; ++r) { for (lint c = 1; c <= r; ++c) { int year; cin >> year; lint required = (r + 1 - c) * c; //cout << required << (c == r ? "\n" : " "); if (required <= k && year < best) { best = year; } } } cout << best << endl; return 0; } |