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

class sum{
    public:
        int k;
        char w;
        int weight;        
};
bool compareWeight(const sum & l, const sum & r){
    return l.weight < r.weight;
};
bool compareK(const sum & l, const sum & r){
    return l.k < r.k;
};
int main(){
    int n;
    int p=-1,s=0,ac;
    cin>>n;
    sum *Sumy = new sum[n];
    for(int i=0;i<n;i++){
        cin>>Sumy[i].weight;
        Sumy[i].k=i;
        Sumy[i].w='T';
    }
    sort(Sumy,&Sumy[n],compareWeight);
    ac=Sumy[0].weight;
    Sumy[0].w='N';
    for(int i=1;i<n;i++){
        s=s+Sumy[i-1].weight;
        if(ac==Sumy[i].weight)Sumy[i].w='N';
        if(Sumy[i].weight>s){
            p=i;
        }
        if(Sumy[i].weight==s)Sumy[i-1].w='N';
    }
    if(p!=-1){
      for(int i=0;i<p;i++)Sumy[i].w='N';
    }
    sort(Sumy,&Sumy[n],compareK);
    for(int i=0;i<n;i++){cout<<Sumy[i].w;}
    cout<<endl;
    return 0;   
}