#include <stdio.h> int main(){ int n,k; scanf("%d", &n); scanf("%d", &k); int min_year = 3000; for (int i = 0; i < n; i++){ for(int j = 0; j<=i; j++){ int barrel; scanf("%d", &barrel); if(((j+1)*(i-j+1)<=k)&&(barrel<min_year)){ min_year = barrel; } } } printf("%d",min_year); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <stdio.h> int main(){ int n,k; scanf("%d", &n); scanf("%d", &k); int min_year = 3000; for (int i = 0; i < n; i++){ for(int j = 0; j<=i; j++){ int barrel; scanf("%d", &barrel); if(((j+1)*(i-j+1)<=k)&&(barrel<min_year)){ min_year = barrel; } } } printf("%d",min_year); } |