#include<iostream> using namespace std; int tab[2000000]; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n,k,najm = 0 ,m = 0,ile = 0; cin>>n>>k; for(int i =0;i<(n*(n+1))/2;i++){ cin>>tab[i]; } najm = tab[0]; for(int i = 0;i<=k/2;i++){ m +=i; for(int j = m;j<m+i;j++){ if(tab[j]<najm) najm = tab[j]; } } cout<<najm; }
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 | #include<iostream> using namespace std; int tab[2000000]; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n,k,najm = 0 ,m = 0,ile = 0; cin>>n>>k; for(int i =0;i<(n*(n+1))/2;i++){ cin>>tab[i]; } najm = tab[0]; for(int i = 0;i<=k/2;i++){ m +=i; for(int j = m;j<m+i;j++){ if(tab[j]<najm) najm = tab[j]; } } cout<<najm; } |