#include<bits/stdc++.h> #define I if #define E else #define W while #define F for #define R return #define S scanf #define P printf using namespace std;int arr[500000];int arr1[500000];int main(){int n,i,nm,r;long long s;S("%d",&n);F(i=0;i<n;i++){S("%d",&arr[i]);arr1[i]=arr[i];}sort(arr,arr+n);r=0;s=0;nm=arr[0];F(i=0;i<n-1;i++){s+=arr[i];I(s<=arr[i+1] || arr[i]==nm)r=arr[i+1];}I(nm==arr[n-1])r=arr[n-1]+1;F(i=0;i<n;i++){I(arr1[i]>=r)P("T");E P("N");}P("\n");}
1 2 3 4 5 6 7 8 9 | #include<bits/stdc++.h> #define I if #define E else #define W while #define F for #define R return #define S scanf #define P printf using namespace std;int arr[500000];int arr1[500000];int main(){int n,i,nm,r;long long s;S("%d",&n);F(i=0;i<n;i++){S("%d",&arr[i]);arr1[i]=arr[i];}sort(arr,arr+n);r=0;s=0;nm=arr[0];F(i=0;i<n-1;i++){s+=arr[i];I(s<=arr[i+1] || arr[i]==nm)r=arr[i+1];}I(nm==arr[n-1])r=arr[n-1]+1;F(i=0;i<n;i++){I(arr1[i]>=r)P("T");E P("N");}P("\n");} |