#include <stdio.h> int N, K; int min = 2020; inline int triangle(int base) { return (base * (base + 1)) >> 1; } int main() { scanf("%d %d", &N, &K); for (int n = 1; n <= N; n++) { for (int i = 1; i <= n; i++) { int date; scanf("%d", &date); int above = n - 1; int leftAbove = i - 2; int rightAbove = n - i -1; int lenght = 1 + triangle(above) - triangle(leftAbove) - triangle(rightAbove); if (lenght <= K) if (date < min) min = date; } } printf("%d", min); }
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 | #include <stdio.h> int N, K; int min = 2020; inline int triangle(int base) { return (base * (base + 1)) >> 1; } int main() { scanf("%d %d", &N, &K); for (int n = 1; n <= N; n++) { for (int i = 1; i <= n; i++) { int date; scanf("%d", &date); int above = n - 1; int leftAbove = i - 2; int rightAbove = n - i -1; int lenght = 1 + triangle(above) - triangle(leftAbove) - triangle(rightAbove); if (lenght <= K) if (date < min) min = date; } } printf("%d", min); } |