#include <bits/stdc++.h> #define st first #define nd second #define pb push_back #define mp make_pair #define boost ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define F(i,k,n) for(int i = k ; i < n ; ++i) #define sz(x) (int)x.size() #define var(x) #x << " " << x #define all(v) (v).begin(), (v).end() using namespace std; typedef long long LL; typedef long double LD; typedef pair<int,int> PII; typedef pair<int,LL> PIL; typedef pair<LL,int> PLI; typedef pair<LL,LL> PLL; typedef vector<int> VI; typedef vector<PII> VII; typedef vector<LL> VLL; const int INF=1e9+7,N=1e3+7; int n,k,wyn=4000,a,b; int main() { boost; cin >> n >> k; for(int i=1;i<=n;i++) for(int j=1;j<=i;j++){ cin >> a; b=i*j-j*(j-1); if(b<=k) wyn=min(wyn,a); } cout << wyn << "\n"; }
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 | #include <bits/stdc++.h> #define st first #define nd second #define pb push_back #define mp make_pair #define boost ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define F(i,k,n) for(int i = k ; i < n ; ++i) #define sz(x) (int)x.size() #define var(x) #x << " " << x #define all(v) (v).begin(), (v).end() using namespace std; typedef long long LL; typedef long double LD; typedef pair<int,int> PII; typedef pair<int,LL> PIL; typedef pair<LL,int> PLI; typedef pair<LL,LL> PLL; typedef vector<int> VI; typedef vector<PII> VII; typedef vector<LL> VLL; const int INF=1e9+7,N=1e3+7; int n,k,wyn=4000,a,b; int main() { boost; cin >> n >> k; for(int i=1;i<=n;i++) for(int j=1;j<=i;j++){ cin >> a; b=i*j-j*(j-1); if(b<=k) wyn=min(wyn,a); } cout << wyn << "\n"; } |