#include <iostream>
#include <math.h>
int N, K;
int BEST = 2020;
int main() {
std::ios::sync_with_stdio(false);
std::cin >> N >> K;
for (int row = 1; row <= N; row ++) {
for (int col = 1; col <= row; col ++) {
int year, bottles = col * (row + 1 - col);
std::cin >> year;
if (bottles <= K)
BEST = std::min(BEST, year);
}
}
std::cout << BEST << std::endl;
}
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> #include <math.h> int N, K; int BEST = 2020; int main() { std::ios::sync_with_stdio(false); std::cin >> N >> K; for (int row = 1; row <= N; row ++) { for (int col = 1; col <= row; col ++) { int year, bottles = col * (row + 1 - col); std::cin >> year; if (bottles <= K) BEST = std::min(BEST, year); } } std::cout << BEST << std::endl; } |
English