#include <bits/stdc++.h> using namespace std; int n; int a[301]; bool test() { for (int i = 2; i <= n; i++) for (int j = 1; j < i; j++) if (a[i] > a[j] + a[i - j]) return false; return true; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", a + i); if (!test()) { printf("NIE\n"); return 0; } printf("TAK\n"); printf("%d\n", n); for (int i = 1; i <= n; i++) printf("%d ", a[i] - a[i - 1]); }
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 | #include <bits/stdc++.h> using namespace std; int n; int a[301]; bool test() { for (int i = 2; i <= n; i++) for (int j = 1; j < i; j++) if (a[i] > a[j] + a[i - j]) return false; return true; } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", a + i); if (!test()) { printf("NIE\n"); return 0; } printf("TAK\n"); printf("%d\n", n); for (int i = 1; i <= n; i++) printf("%d ", a[i] - a[i - 1]); } |