Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///HELLO THERE~!
- ///CREATED BY MD SADMAN MEHEDI SIVAN(IUT CSE-SWE^19)
- #include <bits/stdc++.h>
- #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
- #define read freopen("blue.txt","r",stdin);
- #define write freopen("red.txt","w",stdout);
- #define pie 2*acos(0.0);
- typedef long long ll;
- using namespace std;
- int main()
- {
- fastio;
- ll n;
- cin>>n;
- ll sivan[n+1];
- for(ll i=0; i<n; i++)
- cin>>sivan[i];
- ll temperature[n+1];
- for(ll i=0; i<n; i++)
- cin>>temperature[i];
- vector<ll>future;
- ll sum=0;
- for(ll i=0; i<n; i++)
- {
- if(temperature[i]>=sivan[i])
- {
- sum+=sivan[i];
- }
- else
- {
- //sum+=temperature[i];
- future.push_back(sivan[i]);
- }
- for(int r=0; r<future.size(); r++)
- {
- if(temperature[i]>=future[r])
- {
- sum+=future[r];
- future.erase(future.begin()+r);
- r=r-1;
- }
- else
- {
- sum+=temperature[i];
- future[r]=(abs(future[r]-temperature[i]));
- }
- }
- cout<<sum<<" ";
- sum=0;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment