#include <iostream> #include <vector> #include <string> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int a, s; long long fs = 0; string f = ""; vector<long long>m; vector<long long>tm; cin >> a; for (int i = 0; i < a; i++) { int n; cin >> n; m.push_back(n); tm.push_back(n); } for (int i = 0; i < a; i++) { fs += m[i]; } for (int i = 0; i < a; i++) { s = m[i]; for (int n = 0; n < a; n++) { if (tm[i] == fs) { break; } if (tm[n] < tm[i]&&tm[n]!=0) { tm[i] += tm[n]; s += tm[n]; tm[n] = 0; n = 0; } } if (fs == s) { f += 'T'; } else { f += 'N'; } tm.erase(tm.begin(), tm.end()); tm = m; } cout << f; 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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #include <iostream> #include <vector> #include <string> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int a, s; long long fs = 0; string f = ""; vector<long long>m; vector<long long>tm; cin >> a; for (int i = 0; i < a; i++) { int n; cin >> n; m.push_back(n); tm.push_back(n); } for (int i = 0; i < a; i++) { fs += m[i]; } for (int i = 0; i < a; i++) { s = m[i]; for (int n = 0; n < a; n++) { if (tm[i] == fs) { break; } if (tm[n] < tm[i]&&tm[n]!=0) { tm[i] += tm[n]; s += tm[n]; tm[n] = 0; n = 0; } } if (fs == s) { f += 'T'; } else { f += 'N'; } tm.erase(tm.begin(), tm.end()); tm = m; } cout << f; return 0; } |