#include <stdio.h> #include <stdlib.h> int lines; int bottles; int main() { scanf("%d %d", &lines, &bottles); int best_year = 2020; for (int y = 0; y < lines; y++) { for (int x = 0; x < y + 1; x++) { int year; scanf("%d", &year); int moves = (x + 1) * abs(y - x + 1); if (moves <= bottles) { if (year < best_year) { best_year = year; } } } } printf("%d\n", best_year); }
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 29 | #include <stdio.h> #include <stdlib.h> int lines; int bottles; int main() { scanf("%d %d", &lines, &bottles); int best_year = 2020; for (int y = 0; y < lines; y++) { for (int x = 0; x < y + 1; x++) { int year; scanf("%d", &year); int moves = (x + 1) * abs(y - x + 1); if (moves <= bottles) { if (year < best_year) { best_year = year; } } } } printf("%d\n", best_year); } |