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
#include <bits/stdc++.h>
using namespace std;




int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    vector < pair < int, int > > a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    } 
    sort(a.begin(), a.end());
    vector < long long > b(n);
    b[0] = a[0].first;
    for (int i = 1; i < n; i++) b[i] = b[i - 1] + a[i].first;
    vector < int > ans(n);
    for (int i = 1; i < n; i++) {
        if (a[i].first != a[i - 1].first) {
            long long val = b[i - 1];
            if (a[i].first + val > a[n - 1].first) {
                for (int j = i; j < n && a[j].first == a[i].first; j++) ans[a[j].second] = 1;
            }
        }
    }
    for (int i = 0; i < n; i++) cout << (ans[i] ? 'T' : 'N');
}