#include <algorithm> #include <cstdio> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define INT(x) int x; scanf("%d", &x) int main() { INT(n); INT(k); int r = 3000; REP(i,n) { REP(j,i+1) { INT(a); if ((j + 1) * (i - j + 1) <= k) r = min(r, a); } } printf("%d\n", r); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <algorithm> #include <cstdio> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define INT(x) int x; scanf("%d", &x) int main() { INT(n); INT(k); int r = 3000; REP(i,n) { REP(j,i+1) { INT(a); if ((j + 1) * (i - j + 1) <= k) r = min(r, a); } } printf("%d\n", r); } |