#include<bits/stdc++.h>
using namespace std;
const int M = ((int)(1e9)) + 50;
int a,temp,k,wyn = M;
int calculateTurn(int x, int y){
return x * (y - x + 1);
}
int main(){
ios_base::sync_with_stdio( 0 );
cin.tie( 0 );
cin>>a>>k;
for (int i = 1; i <= a; i++){
for (int j = 1; j <= i; j++){
cin>>temp;
if(calculateTurn(j , i) <= k) {
wyn = min(wyn , temp);
}
}
}
cout<<wyn<<endl;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include<bits/stdc++.h> using namespace std; const int M = ((int)(1e9)) + 50; int a,temp,k,wyn = M; int calculateTurn(int x, int y){ return x * (y - x + 1); } int main(){ ios_base::sync_with_stdio( 0 ); cin.tie( 0 ); cin>>a>>k; for (int i = 1; i <= a; i++){ for (int j = 1; j <= i; j++){ cin>>temp; if(calculateTurn(j , i) <= k) { wyn = min(wyn , temp); } } } cout<<wyn<<endl; } |
English