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 | #include <iostream>
#include <algorithm>
typedef unsigned long long ll;
using namespace std;
int moves(int r,int c)
{
return (c+1)*(r -c+1);
}
int main()
{
int n;
int k;
cin>>n>>k;
int r = 0;
int c = 0;
int res = 2020;
for(int i =0;i<n*(n+1)/2;i++)
{
int a;
cin>>a;
if(moves(r,c) <= k)
res = min(res,a);
c++;
if(c>r)
{
r+=1;
c=0;
}
}
cout<<res<<endl;
}
|