Untitled
unknown
plain_text
24 days ago
1.8 kB
1
Indexable
Never
#include <bits/stdc++.h> using namespace std ; #define For(n) for(long long i = 0; i < n; i++) #define endl '\n' #define int long long int mrseacrh (int arr[],int n,int x){ int l =1;int r = n-1;int ans = r; while(l<=r){ int mid = (l+r)/2; if(arr[mid] >= x){ ans = mid; r = mid -1; } else l = mid +1; } return ans ; } void solve (){ string t;cin>>t; int b=0,s=0,c=0; For(t.length()){ if(t[i]=='B')b++; else if(t[i]=='C')c++; else s++; } int currb,currs,currc;cin>>currb>>currs>>currc; int priceb,prices,pricec;cin>>priceb>>prices>>pricec; int rubls ;cin>>rubls; if(b==0){ b =1; priceb = 0; } if(c==0){ c=1; pricec = 0; } if(s==0){ s=1; prices=0; } //stage int ans = min(currb/b ,currc/c); ans = min (ans,currs/s); currb -= b*ans; currs -= s*ans; currc -= c*ans; //stage 2 if((b-currb)*priceb <=rubls) rubls -= (b-currb)*priceb; else { cout << ans << endl; return; } if((c-currc)*pricec <=rubls) rubls -= (c-currc)*pricec; else { cout << ans << endl; return; } if((s-currs)*prices <=rubls) rubls -= (s-currs)*prices; else { cout << ans << endl; return; } ans ++; //stages3 int totalcost = priceb*b+pricec*c+prices*s; ans += rubls/totalcost; cout << ans << endl; } signed main () { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t =1; // cin>>t; while (t--){ solve(); } }
Leave a Comment