#include <iostream> using namespace std; const int N = 2000; int tab[N][N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k, i, j, x, m; cin>>n>>k; for(i = 0; i < n; i++) { for(j = 0; j <= i; j++) { cin>>tab[i][j]; } } x = tab[0][0]; for(j = 0; j < n;j++) { for(i = j, m = j + 1;m <= k && i < n;i++, m += j + 1) { if(tab[i][j] < x) x = tab[i][j]; } } cout<<x; }
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 | #include <iostream> using namespace std; const int N = 2000; int tab[N][N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k, i, j, x, m; cin>>n>>k; for(i = 0; i < n; i++) { for(j = 0; j <= i; j++) { cin>>tab[i][j]; } } x = tab[0][0]; for(j = 0; j < n;j++) { for(i = j, m = j + 1;m <= k && i < n;i++, m += j + 1) { if(tab[i][j] < x) x = tab[i][j]; } } cout<<x; } |