Created
June 5, 2021 16:59
-
-
Save sumedhaagarwal/6e25999552b6d3116e873d16df3ecd00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#include<map> | |
#define REP(i,a,b) for(int i=a;i<b;i++) | |
#define NREP(i,a,b) for(int i=a;i>=b;i--) | |
#define clr(a) memset(a,0,sizeof a) | |
#define CLR(a,t) memset(a,t,sizeof a) | |
#define help ios::sync_with_stdio(0) | |
#define SORTV(a,n) sort(a.begin(),a.begin()+n) | |
#define SORTA(a,n) sort(a,a+n) | |
#define f first | |
#define ii second | |
#define mp make_pair | |
#define pb push_back | |
typedef long long int ll; | |
typedef long double ld; | |
#define vip vector<pair<ll,ll>> | |
#define vv vector<vector<ll>> | |
#define vvip vector<vector<ipair>> | |
#define vi vector<ll> | |
#define FORS(it,m) for(set<int>::iterator it=m.begin();it!=m.end();it++) | |
#define FORM(it,m) for(map<ll,ll>::iterator it=m.begin();it!=m.end();it++) | |
#define FORV(it,m) for(vector<ll>::iterator it=m.begin();it!=m.end();it++) | |
#define FORL(it,l) for(list<int> :: iterator it=l.begin();it!=l.end();it++) | |
#define MAX6 1000000 | |
#define MAX5 100000 | |
#define MAX4 10000 | |
#define ipair pair<ll,ll> | |
#define iipair pair<ll,pair<ll,ll> > | |
#define deb(x) cout<<#x<<"="<<x<<endl | |
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl | |
#define minHeap priority_queue<iipair,vector<iipair>,greater<iipair>> | |
#define maxHeap priority_queue<ipair> | |
#define iminHeap priority_queue<ll,vector<ll>,greater<ll>> | |
#define imaxHeap priority_queue<ll> | |
#define iMap map<ll,ll> | |
#define iuMap unordered_map<ll, ll> | |
#define piMap map<pair<ll,ll>,ll> | |
#define sz(a) a.size() | |
#define tc(t) ll t; cin>>t; while(t--) | |
#define debArr(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl; | |
#define si cout<<"YES"<<endl; | |
#define nada cout<<"NO"<<endl; | |
template<typename... T> | |
void read(T&... args){((cin>>args),...);} | |
template<typename... T> | |
void write(T&... args){((cout<<args<<" "),...);} | |
ll upperBound(ll a[],ll n,ll val) {return upper_bound(a,a+n,val)-a;} | |
ll lowerBound(ll a[],ll n,ll val) {return lower_bound(a,a+n,val)-a;} | |
bool persqr(int a) { return (int(sqrt(a))*int(sqrt(a))==a)?1:0; } | |
ll gcd(ll a,ll b) { return (a?gcd(b%a,a):b);} | |
bool powerOf2(int a) { return !(a&(a-1));} | |
ll abs(ll n1,ll n2){ return n1>n2?n1-n2:n2-n1;} | |
ll power(ll xx, ll yy){if(yy==0)return 1;ll pp=power(xx,yy/2);return(yy%2==0)?(pp*pp):(pp*pp*xx);} | |
ll highestPowerof2(ll n) { return power(2,(ll)log2(n)); } | |
ll ans,n,t,ans1,cnt=0; | |
ll dp(ll a,ll b,ll c,ll x,ll y,ll z){ | |
if(a!=0 and x!=0) dp(a-min(a,x),b,c,x-min(a,x),y,z); | |
if(a!=0 and z!=0) dp(a-min(a,z),b,c,x,y,z-min(a,z)); | |
if(b!=0 and y!=0) dp(a,b-min(b,y),c,x,y-min(b,y),z); | |
if(b!=0 and x!=0) dp(a,b-min(b,x),c,x-min(b,x),y,z); | |
if(c!=0 and z!=0) dp(a,b,c-min(c,z),x,y,z-min(c,z)); | |
if(c!=0 and y!=0) dp(a,b,c-min(c,y),x,y-min(c,y),z); | |
ans1=min(ans1,a+b+c); | |
return 0; | |
} | |
int main(){ | |
help; | |
ll a,b,c,x,y,z; | |
read(n,a,b,c,x,y,z); | |
ans=min(a,y)+min(b,z)+min(c,x); | |
ans1=a+b+c; | |
dp(a,b,c,x,y,z); | |
cout<<ans1<<" "<<ans<<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment