#include <bits/stdc++.h>
using namespace std;
int tab[500007];
int a[500007];
int f(int y, int n)
{
long long suma=a[y];
bool helpp=true;
for(int i=0; i<n && helpp==true; i++)
{
if(y!=i)
{
if(suma>a[i]) suma+=a[i];
else helpp=false;
}
}
if(helpp==true) return 0;
else return 1;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, x;
cin >> n;
for(int i=0; i<n; i++)
{
cin >> tab[i];
a[i]=tab[i];
}
sort(a, a+n);
for(int i=0; i<n; i++)
{
if(f(i, n)==0)
{
x=a[i];
break;
}
}
for(int i=0; i<n; i++)
{
if(tab[i]>=x) cout << 'T';
else cout << 'N';
}
return 0;
}
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 | #include <bits/stdc++.h> using namespace std; int tab[500007]; int a[500007]; int f(int y, int n) { long long suma=a[y]; bool helpp=true; for(int i=0; i<n && helpp==true; i++) { if(y!=i) { if(suma>a[i]) suma+=a[i]; else helpp=false; } } if(helpp==true) return 0; else return 1; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, x; cin >> n; for(int i=0; i<n; i++) { cin >> tab[i]; a[i]=tab[i]; } sort(a, a+n); for(int i=0; i<n; i++) { if(f(i, n)==0) { x=a[i]; break; } } for(int i=0; i<n; i++) { if(tab[i]>=x) cout << 'T'; else cout << 'N'; } return 0; } |
English