#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> using namespace std; struct paint_compare { bool operator()(const pair<int, int>& a, const pair<int,int>& b) { return a.first < b.first; } }; int main(){ int n; cin >> n; vector<int> numbers; for(int i = 0 ;i < n ; i++){ int tmp; cin >> tmp; numbers.push_back(tmp); } bool possible = true; for(int i = 1; i < n; i ++){ int minx = 20000003; for(int j = 0; j < i; j++){ minx = min(minx, numbers[i - j - 1] + numbers[j]); } if(minx < numbers[i]){ possible = false; } } long long sum = 0; if(!possible){ cout << "NIE"; } else { cout << "TAK" << endl; cout << n << endl; for(int i = 0 ; i < n; i++){ cout << (numbers[i] - sum) << " "; sum = numbers[i]; } } cout << endl; }
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 50 51 | #include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> using namespace std; struct paint_compare { bool operator()(const pair<int, int>& a, const pair<int,int>& b) { return a.first < b.first; } }; int main(){ int n; cin >> n; vector<int> numbers; for(int i = 0 ;i < n ; i++){ int tmp; cin >> tmp; numbers.push_back(tmp); } bool possible = true; for(int i = 1; i < n; i ++){ int minx = 20000003; for(int j = 0; j < i; j++){ minx = min(minx, numbers[i - j - 1] + numbers[j]); } if(minx < numbers[i]){ possible = false; } } long long sum = 0; if(!possible){ cout << "NIE"; } else { cout << "TAK" << endl; cout << n << endl; for(int i = 0 ; i < n; i++){ cout << (numbers[i] - sum) << " "; sum = numbers[i]; } } cout << endl; } |