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