sivan_iut

Untitled

May 4th, 2020
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. ///HELLO THERE~!
  2. ///CREATED BY MD SADMAN MEHEDI SIVAN(IUT CSE-SWE^19)
  3.  
  4. #include <bits/stdc++.h>
  5.  
  6. #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  7. #define read freopen("blue.txt","r",stdin);
  8. #define write freopen("red.txt","w",stdout);
  9. #define pie 2*acos(0.0);
  10.  
  11. typedef long long ll;
  12.  
  13. using namespace std;
  14.  
  15. int  main()
  16. {
  17.     fastio;
  18.  
  19.     ll n;
  20.     cin>>n;
  21.  
  22.     ll sivan[n+1];
  23.     for(ll i=0; i<n; i++)
  24.         cin>>sivan[i];
  25.  
  26.     ll temperature[n+1];
  27.     for(ll i=0; i<n; i++)
  28.         cin>>temperature[i];
  29.  
  30.     vector<ll>future;
  31.     ll sum=0;
  32.  
  33.  
  34.     for(ll i=0; i<n; i++)
  35.     {
  36.  
  37.         if(temperature[i]>=sivan[i])
  38.         {
  39.             sum+=sivan[i];
  40.         }
  41.         else
  42.         {
  43.             //sum+=temperature[i];
  44.             future.push_back(sivan[i]);
  45.  
  46.         }
  47.         for(int r=0; r<future.size(); r++)
  48.         {
  49.             if(temperature[i]>=future[r])
  50.             {
  51.                 sum+=future[r];
  52.                 future.erase(future.begin()+r);
  53.                 r=r-1;
  54.             }
  55.             else
  56.             {
  57.                 sum+=temperature[i];
  58.                 future[r]=(abs(future[r]-temperature[i]));
  59.             }
  60.  
  61.         }
  62.          cout<<sum<<" ";
  63.                 sum=0;
  64.  
  65.  
  66.  
  67.     }
  68.  
  69.     return 0;
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment