Advertisement
Rofyda_Elghadban1

Untitled

Oct 2nd, 2023
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define ull unsigned long long
  4. #define pi 3.141592654
  5. #define NUM 1e18
  6. #define Mod 1'000'000'007
  7. #define fixed(n) fixed<<setprecision(n)
  8. #define cin(v) for(auto &i:v) cin >> i ;
  9. #define cout(v) for(auto &i:v) cout << i <<" ";
  10. #define vowel(x) (x=='e'||x=='a'||x=='i'||x=='o'||x=='u')
  11. #define small(x) (x>=97&&x<=122)
  12. #define capital(x) (x>=65&&x<=90)
  13. #define Tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
  14. #define Toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
  15. #define all(v) ((v).begin()), ((v).end())
  16. #define allr(v) ((v).rbegin()), ((v).rend())
  17. #define updmax(a,b) a=max(a,b)
  18. #define updmin(a,b) a=min(a,b)
  19. #define ceil(a,b) ((a/b)+(a%b?1:0))
  20. /* asc -> 1 2 3 ,des -> 3 2 1 */
  21. /***********************************************************************************/
  22. using namespace std;
  23. void Rofyda_Elghadban(){
  24. #ifndef ONLINE_JUDGE
  25. freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  26. #endif
  27. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  28. }
  29.  
  30. struct com{
  31. bool operator()(int l,int r){
  32. return (l>=50)<(r>=50);
  33. }
  34. };
  35.  
  36. void solve(){
  37. int n,sum=0,counter=0,e=0,maxi1=INT_MIN,maxi2=INT_MIN,ans=0;
  38. cin>>n;
  39. vector<int>v(n),m,p;
  40. cin(v);
  41. for(int i=0;i<n;i++){
  42. sum+=v[i];
  43. //cout<<sum<<"**";
  44. if(sum>=0){
  45. ans++;
  46. // continue;
  47. }else{
  48. //cout<<"\n";
  49. sum-=v[i];
  50. for(int j=0;j<i;j++){
  51. if(v[i]>v[j]&&counter==0){
  52. sum+=v[i];
  53. sum-=v[j];
  54. //cout<<sum<<" ";
  55. counter++;
  56. //ans++;
  57. }
  58. //cout<<"\n";
  59. // else{
  60. // continue;
  61. // }
  62. }
  63. //counter=0;
  64. }
  65. }
  66. cout<<ans<<"\n";
  67. }
  68.  
  69. int main(){
  70. Rofyda_Elghadban();
  71. solve();
  72.  
  73. return 0;
  74. }
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement