#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n,q; int mini = 10000; cin >> n >> q; int val = 0; for(int k=1;k<=n;k++) { for(int i=1;i<=k;i++) { cin >> val; if(i*(k-i+1) <=q ) mini = min(val,mini); //cout << i << " " << k << " " << i*(k-i+1) <<endl; } } cout << mini<<endl; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n,q; int mini = 10000; cin >> n >> q; int val = 0; for(int k=1;k<=n;k++) { for(int i=1;i<=k;i++) { cin >> val; if(i*(k-i+1) <=q ) mini = min(val,mini); //cout << i << " " << k << " " << i*(k-i+1) <<endl; } } cout << mini<<endl; } |