#include <iostream> #include <vector> int main() { int howManyChanges; std::vector<int> changes; std::cin >> howManyChanges; for (int i = 0; i < howManyChanges; i++) { changes.push_back(0); std::cin >> changes[i]; } for (int i = 1; i < howManyChanges; i++) { if (changes[i] > (changes[i - 1] + changes[0])) { std::cout << "NIE"; return 0; } } std::cout << "TAK" << std::endl << howManyChanges << std::endl; std::cout << changes[0]; for (int i = 1; i < howManyChanges; i++) { std::cout << " " << changes[i] - changes[i - 1]; } 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 | #include <iostream> #include <vector> int main() { int howManyChanges; std::vector<int> changes; std::cin >> howManyChanges; for (int i = 0; i < howManyChanges; i++) { changes.push_back(0); std::cin >> changes[i]; } for (int i = 1; i < howManyChanges; i++) { if (changes[i] > (changes[i - 1] + changes[0])) { std::cout << "NIE"; return 0; } } std::cout << "TAK" << std::endl << howManyChanges << std::endl; std::cout << changes[0]; for (int i = 1; i < howManyChanges; i++) { std::cout << " " << changes[i] - changes[i - 1]; } return 0; } |