// Zadanie: Wina
// Autor: Szymon Bednorz
#include <iostream>
#include <vector>
using namespace std;
int calcAccess(int x, int y) {
if (y % 2) {
if (x > y / 2 + 1)
x = y - x + 1;
return (y - x + 1) * x;
}
else {
if (x > y / 2)
x = y - x + 1;
return (y - x + 1) * x;
}
return (y - x + 1) * x;
}
int main() {
int n, k;
cin >> n >> k;
int maxAccess = (n % 2) ? (n - n / 2) * (1 + n / 2) : (n - n / 2 + 1) * (n / 2);
vector<int> access(maxAccess + 1, 2119);
int input;
for (int y = 0; y < n; y++) {
for (int x = 0; x <= y; x++) {
cin >> input;
if (input < access[calcAccess(x+1, y+1)]) {
access[calcAccess(x + 1, y + 1)] = input;
}
}
}
int min = access[0];
if (k > maxAccess)
k = maxAccess - 1;
for (int i = 1; i <= k; i++) {
if (access[i] < min) min = access[i];
}
cout << min;
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | // Zadanie: Wina // Autor: Szymon Bednorz #include <iostream> #include <vector> using namespace std; int calcAccess(int x, int y) { if (y % 2) { if (x > y / 2 + 1) x = y - x + 1; return (y - x + 1) * x; } else { if (x > y / 2) x = y - x + 1; return (y - x + 1) * x; } return (y - x + 1) * x; } int main() { int n, k; cin >> n >> k; int maxAccess = (n % 2) ? (n - n / 2) * (1 + n / 2) : (n - n / 2 + 1) * (n / 2); vector<int> access(maxAccess + 1, 2119); int input; for (int y = 0; y < n; y++) { for (int x = 0; x <= y; x++) { cin >> input; if (input < access[calcAccess(x+1, y+1)]) { access[calcAccess(x + 1, y + 1)] = input; } } } int min = access[0]; if (k > maxAccess) k = maxAccess - 1; for (int i = 1; i <= k; i++) { if (access[i] < min) min = access[i]; } cout << min; return 0; } |
English