fork download
  1. #include <bits/stdc++.h>
  2. #define my_angel QuynhNhu
  3. //#define int long long
  4. #define ll long long
  5. #define ull unsigned long long
  6. #define fi first
  7. #define se second
  8. #define endl "\n"
  9. #define float double
  10. #define ii pair<int,int>
  11. #define all(a) (a).begin(), (a).end()
  12.  
  13. using namespace std;
  14.  
  15. const int N = 5e5 + 5;
  16. const int mod = 1e9 + 7;
  17. const int base = 1301;
  18.  
  19. int n, a[N], b[N];
  20.  
  21. signed main(){
  22. cin.tie(0) -> sync_with_stdio(false);
  23. freopen( "trochoi.inp" , "r" , stdin );
  24. freopen( "trochoi.out" , "w" , stdout );
  25.  
  26. cin >> n;
  27. for (int i = 1; i <= n; ++i){
  28. cin >> a[i];
  29. b[i] = a[i];
  30. }
  31.  
  32. sort(b + 1, b + n + 1);
  33.  
  34. for (int i = 1; i <= n; ++i){
  35. ll tmp = a[i];
  36. bool check = 1, check_ans = 1;
  37. for (int j = 1; j <= n; ++j){
  38. if (b[j] == a[i] && check){
  39. check = 0;
  40. continue;
  41. }
  42. else if (b[j] < tmp) {
  43. tmp = tmp + b[j];
  44. }
  45. else {
  46. check_ans = 0;
  47. break;
  48. }
  49. }
  50. cout << check_ans;
  51. }
  52.  
  53. return 0;
  54. }
  55.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty