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
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull  unsigned long long
#define s second
#define f first
#define mp make_pair
pair<ull,int> sumy[500007];
bool cmp_1(pair<ull,int>a,pair<ull,int>b)
{
    return a.f<b.f;
}
bool cmp_id(pair<ull,int >a,pair<ull,int>b)
{
    return a.s<b.s;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>sumy[i].f;
        sumy[i].s=i;
    }
    sort(sumy,sumy+n,cmp_1);
    
    ull suma=0;
    int small=0;
    for (int i = 0; i < n-1; i++)
    {
        suma+=sumy[i].f;
        if(suma<=sumy[i+1].f)    small=sumy[i].f;
    }
    sort(sumy,sumy+n,cmp_id);
    for (int i = 0; i < n; i++)
    {
        if(sumy[i].f<=small) cout<<'N';
        else cout<<'T';
    }
}