#include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { ios::sync_with_stdio(false); int N, K; cin >> N >> K; int T=2019+1; for (int n=0; n<N; n++) { for (int k=0; k<=n; k++) { int t; cin >> t; if ((k+1)*(n-k+1)<=K && t<T) T=t; } } cout << T << endl; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { ios::sync_with_stdio(false); int N, K; cin >> N >> K; int T=2019+1; for (int n=0; n<N; n++) { for (int k=0; k<=n; k++) { int t; cin >> t; if ((k+1)*(n-k+1)<=K && t<T) T=t; } } cout << T << endl; return 0; } |