#include <cstdio> #include <algorithm> #define REP(a, n) for (int a = 0; a < (n); ++a) #define INF 1000000000 using namespace std; int main() { int best = INF, N, K; scanf("%d%d", &N, &K); REP(row, N) REP(col, row + 1) { int x; scanf("%d", &x); if ((row-col+1)*(col+1)<=K) best = min(best, x); // printf("rok %d wymaga %d\n", x, (row-col+1)*(col+1)); } printf("%d\n", best); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <cstdio> #include <algorithm> #define REP(a, n) for (int a = 0; a < (n); ++a) #define INF 1000000000 using namespace std; int main() { int best = INF, N, K; scanf("%d%d", &N, &K); REP(row, N) REP(col, row + 1) { int x; scanf("%d", &x); if ((row-col+1)*(col+1)<=K) best = min(best, x); // printf("rok %d wymaga %d\n", x, (row-col+1)*(col+1)); } printf("%d\n", best); } |