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
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>

int main()
{
    std::ios_base::sync_with_stdio(false);
    long long int n;
    std::cin>>n;
    std::vector<long long int> sums_i,sums;
    for(int i=0;i<n; ++i)
    {
        long long int s;
        std::cin>>s;
        sums_i.push_back(s);
    }
    sums =sums_i;
    std::sort(sums.begin(), sums.end());
    long long int sumOfSums = 0;
    int last = sums[0];
    for(int i=0; i<n-1; ++i)
    {
        sumOfSums+= sums[i];
        if(sumOfSums <= sums[i+1]) last = sums[i];
    }
    for(const auto& s:sums_i)
    {
        std::cout<< ((s>last)? 'T':'N' );
    }
    return 0;
}