/* Dejwo to ziomal ®© */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector <int> vi; typedef vector <ll> vl; typedef pair <int, int> pi; typedef pair <ll, ll> pl; typedef tuple <int, int, int> ti; typedef vector < pl > vpl; typedef vector < pi > vpi; typedef vector < ti > vti; //double t = clock(); //cout << (clock() - t) / CLOCKS_PER_SEC <<endl; bool debug = false; #define deb if(debug) #define pb push_back #define FOR(i,x,n) for(int i = x; i < n; i++) #define SIZE (3 * 1e5 + 42) #define MAX (1000000 + 42) #define MOD (1000000000 + 9) #define DRZ (2<<21) #define PI 3.14159265 int solve() { int n, m; cin >> n >> m; int M[ n ][ n ], H[ n ][ n ]; FOR(i, 0, n) FOR(j, 0, n) M[ i ][ j ] = (i - j + 1) * (j + 1); int ans = INT_MAX; FOR(i, 0, n) { FOR(j, 0, i + 1) { cin >> H[ i ][ j ]; if(M[ i ][ j ] <= m) ans = min(ans, H[ i ][ j ]); } } return ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); FOR(i, 0, 1) { cout << solve() << 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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | /* Dejwo to ziomal ®© */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector <int> vi; typedef vector <ll> vl; typedef pair <int, int> pi; typedef pair <ll, ll> pl; typedef tuple <int, int, int> ti; typedef vector < pl > vpl; typedef vector < pi > vpi; typedef vector < ti > vti; //double t = clock(); //cout << (clock() - t) / CLOCKS_PER_SEC <<endl; bool debug = false; #define deb if(debug) #define pb push_back #define FOR(i,x,n) for(int i = x; i < n; i++) #define SIZE (3 * 1e5 + 42) #define MAX (1000000 + 42) #define MOD (1000000000 + 9) #define DRZ (2<<21) #define PI 3.14159265 int solve() { int n, m; cin >> n >> m; int M[ n ][ n ], H[ n ][ n ]; FOR(i, 0, n) FOR(j, 0, n) M[ i ][ j ] = (i - j + 1) * (j + 1); int ans = INT_MAX; FOR(i, 0, n) { FOR(j, 0, i + 1) { cin >> H[ i ][ j ]; if(M[ i ][ j ] <= m) ans = min(ans, H[ i ][ j ]); } } return ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); FOR(i, 0, 1) { cout << solve() << endl; } return 0; } |