#include <iostream> using namespace std; int main() { int n; scanf(" %i",&n); int* args = new int[n+1]; args[0] = 0; int* odp = new int[n+1]; for (int i = 1; i <= n; i++) { scanf(" %i",&args[i]); for (int x = i - 1; x > 0;x--) { if (args[x] + args[i - x] < args[i]) { printf("NIE\n"); return 0; } } odp[i] = args[i] - args[i - 1]; } printf("TAK\n"); printf("%i\n", n); for (int i = 1; i <= n; i++) printf("%i ", odp[i]); 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 | #include <iostream> using namespace std; int main() { int n; scanf(" %i",&n); int* args = new int[n+1]; args[0] = 0; int* odp = new int[n+1]; for (int i = 1; i <= n; i++) { scanf(" %i",&args[i]); for (int x = i - 1; x > 0;x--) { if (args[x] + args[i - x] < args[i]) { printf("NIE\n"); return 0; } } odp[i] = args[i] - args[i - 1]; } printf("TAK\n"); printf("%i\n", n); for (int i = 1; i <= n; i++) printf("%i ", odp[i]); return 0; } |