#include <iostream> #include <vector> std::vector<int> vec; int main() { bool ok = true; int n, temp, suma = 0; std::cin>>n; float maxMean = 0, newMean; std::cin>>maxMean; vec.push_back((int)maxMean); suma = vec[0]; for(int a = 1; a < n; a++){ std::cin>>temp; if(!ok) continue; newMean = temp / (a+1); if(newMean > maxMean) ok = false; else{ maxMean = newMean; vec.push_back(temp - suma); suma = temp; } } if(ok){ std::cout<<"TAK\n"<<vec.size()<<"\n"; for(auto a: vec) std::cout<<a<<" "; return 0; } std::cout<<"NIE"; } /* 10 3 1 4 1 5 9 2 6 5 3 */
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 39 40 41 42 43 44 45 46 47 48 49 | #include <iostream> #include <vector> std::vector<int> vec; int main() { bool ok = true; int n, temp, suma = 0; std::cin>>n; float maxMean = 0, newMean; std::cin>>maxMean; vec.push_back((int)maxMean); suma = vec[0]; for(int a = 1; a < n; a++){ std::cin>>temp; if(!ok) continue; newMean = temp / (a+1); if(newMean > maxMean) ok = false; else{ maxMean = newMean; vec.push_back(temp - suma); suma = temp; } } if(ok){ std::cout<<"TAK\n"<<vec.size()<<"\n"; for(auto a: vec) std::cout<<a<<" "; return 0; } std::cout<<"NIE"; } /* 10 3 1 4 1 5 9 2 6 5 3 */ |