#include <bits/stdc++.h> // #pragma GCC optimize ("O3") // #pragma GCC target ("sse4") using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int,int> PII; #define REP(i,n) for(int i=0;i<(n);++i) #define FOR(i,a,b) for (int i=(a); i<(b); ++i) #define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i) #define MAX(dst,src) dst = max(dst, (src)) #define MIN(dst,src) dst = min(dst, (src)) #define pb push_back #define mp make_pair #define st first #define nd second void scase() { int N, K; if (scanf("%d%d", &N, &K) < 2) { exit(0); } int result = 3000; FOR(i,1,N+1)FOR(j,1,i+1) { int value; scanf("%d", &value); int w = min(j,i-j+1); int k = w * (i-w+1); if (k <= K) MIN(result, value); } printf("%d\n", result); } int main(int argc, char* argv[]) { while(true) scase(); }
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 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <bits/stdc++.h> // #pragma GCC optimize ("O3") // #pragma GCC target ("sse4") using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int,int> PII; #define REP(i,n) for(int i=0;i<(n);++i) #define FOR(i,a,b) for (int i=(a); i<(b); ++i) #define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i) #define MAX(dst,src) dst = max(dst, (src)) #define MIN(dst,src) dst = min(dst, (src)) #define pb push_back #define mp make_pair #define st first #define nd second void scase() { int N, K; if (scanf("%d%d", &N, &K) < 2) { exit(0); } int result = 3000; FOR(i,1,N+1)FOR(j,1,i+1) { int value; scanf("%d", &value); int w = min(j,i-j+1); int k = w * (i-w+1); if (k <= K) MIN(result, value); } printf("%d\n", result); } int main(int argc, char* argv[]) { while(true) scase(); } |