#include <iostream>
using namespace std;
int is_possible(int x);
int n;
int value[301];
int main()
{
value[0] = 0;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> value[i];
// Test czy podana wartość jest możliwa uwzględniając poprzednie wartości
if (!is_possible(i)) {
cout << "NIE" << endl;
return 0;
}
}
cout << "TAK" << endl;
cout << n << endl;
for (int i = 1; i <= n; ++i) {
cout << value[i] - value[i - 1]<<" ";
}
return 0;
}
int is_possible(int x) {
for (int j = x - 1; j > x / 2; --j) {
if (value[j] + value[x - j] < value[x]) {
return 0;
}
}
return 1;
}
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 | #include <iostream> using namespace std; int is_possible(int x); int n; int value[301]; int main() { value[0] = 0; cin >> n; for (int i = 1; i <= n; ++i) { cin >> value[i]; // Test czy podana wartość jest możliwa uwzględniając poprzednie wartości if (!is_possible(i)) { cout << "NIE" << endl; return 0; } } cout << "TAK" << endl; cout << n << endl; for (int i = 1; i <= n; ++i) { cout << value[i] - value[i - 1]<<" "; } return 0; } int is_possible(int x) { for (int j = x - 1; j > x / 2; --j) { if (value[j] + value[x - j] < value[x]) { return 0; } } return 1; } |
English