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
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int n, d;
vector<int> v1, v2;

int main() {
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++) {
    	cin >> d;
    	v1.push_back(d);
    	v2.push_back(d);
    }
    sort(v1.begin(), v1.end());
    bool first_value = true;
    long long tmp = 0L;
    int last_break = 0;

    for (int i=0; i < v1.size(); i++) {
    	tmp += (long long) v1[i];
    	if (first_value && i > 0 && v1[i] != v1[i-1]) {
    		first_value = false;
    	}
    	if (i < v1.size() - 1) {
    		if (first_value) {
    			if (v1[i+1] >= v1[i]) {
    				last_break = v1[i];
    			}
    		} else {
    			if (v1[i+1] >= tmp) {
    				last_break = v1[i];
    			}
    		}
    	}
    }
    if (first_value) {
    	last_break = v1[0];
    }
    for(int i = 0; i < v2.size(); i++) {
    	if (v2[i] > last_break) {
    		cout << "T";
    	} else {
    		cout << "N";
    	}
    }
	return 0;
}