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
56
57
#include <iostream>
#include <queue>
using namespace std;

int main()
{
    priority_queue <long, vector<long>, greater<long> > pq;

    vector <long> all;
    int n;
    long weight;
    long a1,a2;
    cin>>n;

    all.resize(n);

    for(int i = 0;i<n;++i)
    {
        cin>>weight;
        all[i] = weight;
    }
    
    for(int i=0;i<n;++i)
    {
        
        for(int j=0;j<n;++j)
        {
            if(j == i) continue;
            pq.push(all[j]);
        }

        a1 = all[i];
    
        while (!pq.empty())
        {
            a2 = pq.top();
            if(a1>a2)
            {
                a1 = a1+a2;
                pq.pop();
            }
            else
            {
                cout<<"N";
                break;
            }
        }

        if(pq.empty()) cout<<"T";
        else
        {
            pq = priority_queue <long, vector<long>, greater<long> >();
        }
    }

    return 0;
}