#include <iostream> using namespace std; int main() { // std::ifstream in("./input.txt"); // std::cin.rdbuf(in.rdbuf()); int n,k,tmp,additive,val,min=2147483647; cin>>n; cin>>k; for (int i=1;i<n+1;i++){ tmp=i; additive=i-2; for(int j=0;j<i;j++){ cin >> val; tmp+=additive; additive-=2; if (tmp<=k && val<min) min=val; } } cout<<min<<endl; 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 | #include <iostream> using namespace std; int main() { // std::ifstream in("./input.txt"); // std::cin.rdbuf(in.rdbuf()); int n,k,tmp,additive,val,min=2147483647; cin>>n; cin>>k; for (int i=1;i<n+1;i++){ tmp=i; additive=i-2; for(int j=0;j<i;j++){ cin >> val; tmp+=additive; additive-=2; if (tmp<=k && val<min) min=val; } } cout<<min<<endl; return 0; } |