#include <bits/stdc++.h> #define FOR(i, a, b) for (int i=(a); i<(b); i++) #define PPC(x) __builtin_popcountll((x)) #define ALL(x) (x).begin(), (x).end() #define pb push_back using namespace std; const int maxN = 2222; int T[maxN][maxN]; int main() { int n, k, res; scanf ("%d%d%d", &n, &k, &res); T[1][1] = 1; FOR(i, 2, n+1) FOR(j, 1, i+1) { T[i][j] = T[i-1][j-1] + T[i-1][j] - T[i-2][j-1] + 1; int a; scanf ("%d", &a); if (T[i][j] <= k) res = min(res, a); } printf("%d\n", res); 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 25 26 27 | #include <bits/stdc++.h> #define FOR(i, a, b) for (int i=(a); i<(b); i++) #define PPC(x) __builtin_popcountll((x)) #define ALL(x) (x).begin(), (x).end() #define pb push_back using namespace std; const int maxN = 2222; int T[maxN][maxN]; int main() { int n, k, res; scanf ("%d%d%d", &n, &k, &res); T[1][1] = 1; FOR(i, 2, n+1) FOR(j, 1, i+1) { T[i][j] = T[i-1][j-1] + T[i-1][j] - T[i-2][j-1] + 1; int a; scanf ("%d", &a); if (T[i][j] <= k) res = min(res, a); } printf("%d\n", res); return 0; } |