#include <iostream> using namespace std; int b[2000]{0}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N, K; cin >> N >> K; int min_y = 2019; for (int i = 1; i <= K; i++) { for (int j = 0; j < i; j++) { b[j] += j+1; int y; cin >> y; if (b[j] <= K && min_y > y) min_y = y; } } cout << min_y << "\n"; return 0; }
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; int b[2000]{0}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N, K; cin >> N >> K; int min_y = 2019; for (int i = 1; i <= K; i++) { for (int j = 0; j < i; j++) { b[j] += j+1; int y; cin >> y; if (b[j] <= K && min_y > y) min_y = y; } } cout << min_y << "\n"; return 0; } |