#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
long long n,k; cin >> n >> k;
long long res = 1e18;
for(long long i = 1; i <= n; i++){
for(long long j = 1; j <= i; j++){
long long x; cin >> x;
long long used = j*(i-j+1);
if(used <= k) res = min(res,x);
}
}
cout << res << "\n";
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n,k; cin >> n >> k; long long res = 1e18; for(long long i = 1; i <= n; i++){ for(long long j = 1; j <= i; j++){ long long x; cin >> x; long long used = j*(i-j+1); if(used <= k) res = min(res,x); } } cout << res << "\n"; } |
English