#include<cstdio> #include<cmath> #include<vector> #include<iostream> #include<string> #include<algorithm> using namespace std; int main(){ int n; scanf("%d", &n); vector<int> org_sumy(n); vector<int> sort_sumy(n); long long int masa = 0; long long int dostepna_masa; for( int i=0; i < n; i++){ scanf("%d", &org_sumy[i]); sort_sumy[i] = org_sumy[i]; masa += org_sumy[i]; } sort(sort_sumy.begin(), sort_sumy.end()); int mini_sum = sort_sumy[0]; int mini_king = sort_sumy[n-1]; dostepna_masa = masa; for (int i = n-1; i >= 0; i--){ if (sort_sumy[i] == mini_sum) break; if(dostepna_masa > mini_king){ mini_king = sort_sumy[i]; dostepna_masa -= mini_king; } else{ break; } } if ( mini_king == mini_sum) mini_king++; for( auto sum: org_sumy){ if ( sum >= mini_king) printf("T"); else printf("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<cstdio> #include<cmath> #include<vector> #include<iostream> #include<string> #include<algorithm> using namespace std; int main(){ int n; scanf("%d", &n); vector<int> org_sumy(n); vector<int> sort_sumy(n); long long int masa = 0; long long int dostepna_masa; for( int i=0; i < n; i++){ scanf("%d", &org_sumy[i]); sort_sumy[i] = org_sumy[i]; masa += org_sumy[i]; } sort(sort_sumy.begin(), sort_sumy.end()); int mini_sum = sort_sumy[0]; int mini_king = sort_sumy[n-1]; dostepna_masa = masa; for (int i = n-1; i >= 0; i--){ if (sort_sumy[i] == mini_sum) break; if(dostepna_masa > mini_king){ mini_king = sort_sumy[i]; dostepna_masa -= mini_king; } else{ break; } } if ( mini_king == mini_sum) mini_king++; for( auto sum: org_sumy){ if ( sum >= mini_king) printf("T"); else printf("N"); } return 0; } |