#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int h, but; cin >> h >> but; int max = 0; int c; for(int r = 0; r < h; r ++){ for(int k = 1; k -1 <= r; k ++){ cin >> c; if(r == 0 && k == 1) max = c; if((r-k+ 2)*k <= but && c < max) max = c; } } cout << max; }
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 | #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int h, but; cin >> h >> but; int max = 0; int c; for(int r = 0; r < h; r ++){ for(int k = 1; k -1 <= r; k ++){ cin >> c; if(r == 0 && k == 1) max = c; if((r-k+ 2)*k <= but && c < max) max = c; } } cout << max; } |