#include <iostream> #include <vector> #define minus_10_13 -10000000000000 int main() { int n = 0; std::cin >> n; std::vector<long long> maxDiffs(n, 0); std::vector<long long> output(n, 0); std::cin >> maxDiffs[0]; output[0] = maxDiffs[0]; for (int i = 1; i < n; i++) { std::cin >> maxDiffs[i]; output[i] = maxDiffs[i] - maxDiffs[i-1]; for (int j = 0; j < i; j++) { int sum = 0; for (int k = 0; k <= j; k++) { sum += output[i - k]; } if (sum > maxDiffs[j]) { std::cout << "NIE"; return 0; } } } printf("TAK\n%d\n%lld %lld", ((3 + n) * n) / 2, output[0], minus_10_13); for (int i = 1; i < n; i++) { for (int j = 0; j < i + 1; j++) printf(" %lld", output[j]); printf(" %lld", minus_10_13); } 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 31 32 33 34 35 36 37 38 | #include <iostream> #include <vector> #define minus_10_13 -10000000000000 int main() { int n = 0; std::cin >> n; std::vector<long long> maxDiffs(n, 0); std::vector<long long> output(n, 0); std::cin >> maxDiffs[0]; output[0] = maxDiffs[0]; for (int i = 1; i < n; i++) { std::cin >> maxDiffs[i]; output[i] = maxDiffs[i] - maxDiffs[i-1]; for (int j = 0; j < i; j++) { int sum = 0; for (int k = 0; k <= j; k++) { sum += output[i - k]; } if (sum > maxDiffs[j]) { std::cout << "NIE"; return 0; } } } printf("TAK\n%d\n%lld %lld", ((3 + n) * n) / 2, output[0], minus_10_13); for (int i = 1; i < n; i++) { for (int j = 0; j < i + 1; j++) printf(" %lld", output[j]); printf(" %lld", minus_10_13); } return 0; } |