#include <bits/stdc++.h> using namespace std; #define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i) #define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i) #define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i) #define PB push_back #define MP make_pair #define ST first #define ND second typedef long long ll; typedef pair<int,int> pii; int k,n,x; int ans=1e9; int main() { ios_base::sync_with_stdio(false);cin.tie(0); cin>>n>>k; FORE(i,1,n){ FORE(j,1,i){ cin>>x; if(x<ans&&(i-j+1)*j<=k){ ans=x; } } } cout<<ans<<"\n"; 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 | #include <bits/stdc++.h> using namespace std; #define FOR(i,x,y) for(int i=(int)(x);i<(int)(y);++i) #define FORE(i,x,y) for(int i=(int)(x);i<=(int)(y);++i) #define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i) #define PB push_back #define MP make_pair #define ST first #define ND second typedef long long ll; typedef pair<int,int> pii; int k,n,x; int ans=1e9; int main() { ios_base::sync_with_stdio(false);cin.tie(0); cin>>n>>k; FORE(i,1,n){ FORE(j,1,i){ cin>>x; if(x<ans&&(i-j+1)*j<=k){ ans=x; } } } cout<<ans<<"\n"; return 0; } |