#include <bits/stdc++.h> using namespace std; long long tab[1000005]; long long sor[1000005]; long long wyn[1000005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, l=0, w=1e9+5, najm=1e9+5; cin>>n; for (int i=0; i<n; i++) { cin>>tab[i]; sor[i] = tab[i]; najm = min(najm, tab[i]); } sort(sor, sor+n); wyn[0] = sor[0]; for (int i=1; i<n; i++) wyn[i] = wyn[i-1] + sor[i]; for (int i=0; sor[i] == najm; i++) wyn[i] = najm; for (int i=0; i<n; i++) { if (wyn[i] < sor[i + 1] + 1 && sor[i + 1] != najm) w = sor[i + 1]; } for (int i=0; i<n; i++) { if (tab[i] >= w) 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 | #include <bits/stdc++.h> using namespace std; long long tab[1000005]; long long sor[1000005]; long long wyn[1000005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, l=0, w=1e9+5, najm=1e9+5; cin>>n; for (int i=0; i<n; i++) { cin>>tab[i]; sor[i] = tab[i]; najm = min(najm, tab[i]); } sort(sor, sor+n); wyn[0] = sor[0]; for (int i=1; i<n; i++) wyn[i] = wyn[i-1] + sor[i]; for (int i=0; sor[i] == najm; i++) wyn[i] = najm; for (int i=0; i<n; i++) { if (wyn[i] < sor[i + 1] + 1 && sor[i + 1] != najm) w = sor[i + 1]; } for (int i=0; i<n; i++) { if (tab[i] >= w) cout<<"T"; else cout<<"N"; } return 0; } |