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

long long ile_sumow, wagi[5000010], suma, start[5000010], minsum;

int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>ile_sumow;
    for(int i=0;i<ile_sumow;i++){
        cin>>wagi[i];
        start[i]=wagi[i];
        suma=suma+wagi[i];
    }
    if(ile_sumow==1){
        cout<<"T";
        return 0;
    }
    //cout<<suma;
    //cout<<endl;
    sort (wagi,wagi+ile_sumow, greater<long long>());
    /*for(int i=0;i<ile_sumow;i++){
        cout<<wagi[i]<<endl;
    }*/
    minsum=wagi[0]+1;
    for(int i=0;i<ile_sumow;i++){
        if(wagi[i]==wagi[ile_sumow-1]){
            break;
        }
        suma=suma-wagi[i];
        if(minsum>wagi[i])
            minsum=wagi[i];
        if(wagi[i]<suma){
            }
        else
            break;
    }
    for(int i=0;i<ile_sumow;i++){
        if(start[i]>=minsum)
            cout<<"T";
        else
            cout<<"N";
    }
    return 0;
}