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

#ifdef KICIA
#define DEBUG(x) x
#else
#define DEBUG(x)
#endif // KICIA

int main(){
    ios_base::sync_with_stdio(0);
    int n, temp = 0;
    cin>>n;
    long long tab[n], sumy[n], tab_copy[n];
    long long mini, mini_krol;
    int czy_krol[n];
    for(int i=0; i<n; ++i){
        cin>>tab[i];
        tab_copy[i] = tab[i];
        if(tab[0] == tab[i]){
            temp++;
        }
    }
    if(temp == n){
        for(int i=0; i<n; ++i){
            cout<<"N";
        }
        return 0;
    }
    sort(&tab[0], &tab[n]);
    sumy[0] = tab[0];
    mini = tab[0];
    for(int i=1; i<n; ++i){
        sumy[i] = sumy[i-1] + tab[i];
    }
    for(int i= n-1; i>=0; --i){
        if(i == (n-1)){
            continue;
        }
        if(sumy[i] > tab[i+1] && tab[i] > mini){
        }else{
            mini_krol = tab[i+1];
            break;
        }
    }
    for(int i =0; i< n; ++i){
        if(tab_copy[i]< mini_krol){
            cout<<"N";
        }else{
            cout<<"T";
        }
    }
    return 0;
}