#include <iostream> using namespace std; int main() { int n, k; cin>>n>>k; int best_year = 2019; for (int level =1 ; level<=n; level ++ ) for (int offset = 1; offset<=level; offset++) { int year; cin>>year; if ( k>= offset*(level-offset +1) ) //tyle trzeba butewlek zdjąć by sie do tej dostać best_year = min(best_year,year); } cout << best_year << endl; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <iostream> using namespace std; int main() { int n, k; cin>>n>>k; int best_year = 2019; for (int level =1 ; level<=n; level ++ ) for (int offset = 1; offset<=level; offset++) { int year; cin>>year; if ( k>= offset*(level-offset +1) ) //tyle trzeba butewlek zdjąć by sie do tej dostać best_year = min(best_year,year); } cout << best_year << endl; return 0; } |