#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define st first #define nd second #define pb push_back #define rep(i,a,b) for(ll i=a;i<=b;i++) #define all(a) a.begin(),a.end() const int mxN = 5e5+7; ll a[mxN]; map<ll,ll> mapka; bool odp[mxN]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; rep(i,1,n) cin >> a[i]; rep(i,1,n) mapka[a[i]]++; ll suma = 0; int od = 0; for(auto u : mapka){ if(suma > u.st) suma += u.st*u.nd; else{ if(suma == 0) od = u.st+1; else od = u.st; suma += u.st*u.nd; } } rep(i,1,n) cout << ((a[i] >= od) ? "T" : "N"); cout << "\n"; }
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 | #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define st first #define nd second #define pb push_back #define rep(i,a,b) for(ll i=a;i<=b;i++) #define all(a) a.begin(),a.end() const int mxN = 5e5+7; ll a[mxN]; map<ll,ll> mapka; bool odp[mxN]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; rep(i,1,n) cin >> a[i]; rep(i,1,n) mapka[a[i]]++; ll suma = 0; int od = 0; for(auto u : mapka){ if(suma > u.st) suma += u.st*u.nd; else{ if(suma == 0) od = u.st+1; else od = u.st; suma += u.st*u.nd; } } rep(i,1,n) cout << ((a[i] >= od) ? "T" : "N"); cout << "\n"; } |