#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxN = 2003; int N, K, year, result = 2020; int main() { scanf("%d%d", &N, &K); for(int row = 1; row < N + 1; row ++) for(int place = 1; place < row + 1; place ++) { scanf("%d", &year); if((row - place + 1) * place <= K) result = min(result, year); } printf("%d\n", result); 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 | #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxN = 2003; int N, K, year, result = 2020; int main() { scanf("%d%d", &N, &K); for(int row = 1; row < N + 1; row ++) for(int place = 1; place < row + 1; place ++) { scanf("%d", &year); if((row - place + 1) * place <= K) result = min(result, year); } printf("%d\n", result); return 0; } |