#include <bits/stdc++.h> using namespace std; map <long long,long long> m; map <long long,long long>::iterator it,iter; long long t[1000005]; long long n; long long gr; long long sum; int main() { std::ios_base::sync_with_stdio(0); cin>>n; for(int i=0;i<n;i++) { cin>>t[i]; m[t[i]]++; } if(m.size()==1) { for(int i=0;i<n;i++) cout<<"N"; return 0; } it=m.begin(); gr=it->first; sum=gr*it->second; it++; iter=it; iter++; while(iter!=m.end()) { sum+=(it->first*it->second); if(sum<=iter->first) { gr=it->first; } it++;iter++; } for(int i=0;i<n;i++) { if(t[i]>gr)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 | #include <bits/stdc++.h> using namespace std; map <long long,long long> m; map <long long,long long>::iterator it,iter; long long t[1000005]; long long n; long long gr; long long sum; int main() { std::ios_base::sync_with_stdio(0); cin>>n; for(int i=0;i<n;i++) { cin>>t[i]; m[t[i]]++; } if(m.size()==1) { for(int i=0;i<n;i++) cout<<"N"; return 0; } it=m.begin(); gr=it->first; sum=gr*it->second; it++; iter=it; iter++; while(iter!=m.end()) { sum+=(it->first*it->second); if(sum<=iter->first) { gr=it->first; } it++;iter++; } for(int i=0;i<n;i++) { if(t[i]>gr)cout<<"T"; else cout<<"N"; } return 0; } |