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
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <climits>
using namespace std;

int n, maxT = INT_MAX, najm = INT_MAX;
long long int suma;
vector<int> V;
vector<int> we;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0, w1; i < n; i++) {
        cin >> w1;
        najm = min(najm, w1);
        suma += w1;
        V.push_back(w1);
        we.push_back(w1);
    }
    V.push_back(INT_MAX);
    sort(V.rbegin(), V.rend());
    V.push_back(INT_MAX);
    V[0] = 0;
    for (int i = 1; i <= n; i++) if (V[i] != najm) {
        //cout << suma << " ";
        if (V[i - 1] >= suma) {
            maxT = V[i];
            break;
        }
        suma -= V[i];
        while (V[i + 1] == V[i]) {
            i++;
            suma -= V[i];
        }
    }
    if (maxT == INT_MAX)
        maxT = najm;
    //cout << endl;
    for (int a : we)
        if (a > maxT)
            cout << 'T';
        else
            cout << 'N';
    return 0;
}