#include <iostream> #include<cstdio> #include<algorithm> using namespace std; #define MAX 2003 #define REP(x, n) for(int x = 0;x < n; x++) #define FOR(x, b, e) for(int x = b, x <= e; x++) int main(){ int n, k, a; int min_year=2019; scanf("%d%d", &n, &k); REP(x, n){ REP(y, x+1){ scanf("%d", &a); if((y+1)*(x-y+1)<=k && a < min_year) min_year = a; // cout<<x<<" "<<y<<" "<<(y+1)<<" "<<x-y+1<<" "<<min_year<<endl; } } printf("%d\n", min_year); 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 | #include <iostream> #include<cstdio> #include<algorithm> using namespace std; #define MAX 2003 #define REP(x, n) for(int x = 0;x < n; x++) #define FOR(x, b, e) for(int x = b, x <= e; x++) int main(){ int n, k, a; int min_year=2019; scanf("%d%d", &n, &k); REP(x, n){ REP(y, x+1){ scanf("%d", &a); if((y+1)*(x-y+1)<=k && a < min_year) min_year = a; // cout<<x<<" "<<y<<" "<<(y+1)<<" "<<x-y+1<<" "<<min_year<<endl; } } printf("%d\n", min_year); return 0; } |