#include <cstdio> void solve(int n) { int v[300 + 9]; for (int i=1; i<=n; ++i) { scanf("%d", v + i); for (int a=1, b=i-1; a<=b; ++a, --b) { if (v[a] + v[b] < v[i]) { printf("NIE\n"); return; } } } printf("TAK\n%d\n%d", n, v[1]); for (int i=1; i<n; ++i) printf(" %d", v[i+1] - v[i]); printf("\n"); } int main() { int n; scanf("%d", &n); solve(n); 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 | #include <cstdio> void solve(int n) { int v[300 + 9]; for (int i=1; i<=n; ++i) { scanf("%d", v + i); for (int a=1, b=i-1; a<=b; ++a, --b) { if (v[a] + v[b] < v[i]) { printf("NIE\n"); return; } } } printf("TAK\n%d\n%d", n, v[1]); for (int i=1; i<n; ++i) printf(" %d", v[i+1] - v[i]); printf("\n"); } int main() { int n; scanf("%d", &n); solve(n); return 0; } |