/** Kajetan Lewandowski **/
#include <bits/stdc++.h>
using namespace std;
int t[2001];
int main() {
int n,k,w,maks=2020;
scanf("%d%d",&n,&k);
for(int i=1; i<=n; ++i){
for(int j=1; j<=i; ++j){
scanf("%d",&w);
t[j]+=j;
if(t[j]<=k && w<maks)maks=w;
}
}
printf("%d",maks);
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /** Kajetan Lewandowski **/ #include <bits/stdc++.h> using namespace std; int t[2001]; int main() { int n,k,w,maks=2020; scanf("%d%d",&n,&k); for(int i=1; i<=n; ++i){ for(int j=1; j<=i; ++j){ scanf("%d",&w); t[j]+=j; if(t[j]<=k && w<maks)maks=w; } } printf("%d",maks); } |
English