#include <bits/stdc++.h> #define ll long long int #define mp make_pair #define pb push_back #define ld long double #define pa pair<int,int> #define st first #define nd second #define vi vector<int> #define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); //#pragma GCC target ("avx2") //#pragma GCC optimization ("O3") //#pragma GCC optimization ("unroll-loops") using namespace std; const int inf=1e9+9; int ans=inf; int main() { BOOST; int n,k; cin>>n>>k; for (int i=1;i<=n;i++) { for (int j=1;j<=i;j++) { int pole=j*(i-j+1); int a; cin>>a; if (pole<=k)ans=min(ans,a); } } cout<<ans; 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 | #include <bits/stdc++.h> #define ll long long int #define mp make_pair #define pb push_back #define ld long double #define pa pair<int,int> #define st first #define nd second #define vi vector<int> #define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); //#pragma GCC target ("avx2") //#pragma GCC optimization ("O3") //#pragma GCC optimization ("unroll-loops") using namespace std; const int inf=1e9+9; int ans=inf; int main() { BOOST; int n,k; cin>>n>>k; for (int i=1;i<=n;i++) { for (int j=1;j<=i;j++) { int pole=j*(i-j+1); int a; cin>>a; if (pole<=k)ans=min(ans,a); } } cout<<ans; return 0; } |