fork download
  1. #include<bits/stdc++.h> // xau nen
  2. using namespace std;
  3. map <char,int> mp1, mp2,mp3;
  4. int th1,th2,th1r=-9999,th2r=-9999;
  5. void nhap()
  6. {
  7. char x[1000];
  8. cin>>x;
  9. for (int i=0; i<strlen(x); i++)
  10. {
  11. if (x[i]<'a')
  12. {
  13. int z=i, t=0;
  14. while (x[z]<'a'&&z<strlen(x)){t=t*10+(int(x[z])-48); z++;}
  15. mp1[x[i-1]]+=t;
  16. if(mp2[x[i-1]]<t)mp2[x[i-1]]=t;
  17. i=z;
  18. }
  19. }
  20. cin>>x;
  21. for (int i=0; i<strlen(x); i++)
  22. {
  23. if(x[i]<'a')
  24. {
  25. int z=i, t=0;
  26. while (x[z]<'a'&&z<strlen(x)){t=t*10+int(x[z])-48; z++;}
  27. //th1=min(mp1[x[i-1]],t);
  28. mp3[x[i-1]]+=t;
  29. th2=min(mp2[x[i-1]],t);
  30. th2r=max(th2,th2r);
  31. i=z;
  32. }
  33. }
  34. for (auto x:mp1)
  35. {
  36. th1=min(x.second,mp3[x.first]);
  37. th1r=max(th1,th1r);
  38. }
  39. }
  40. int main()
  41. {
  42. // freopen ("comstr.inp", "r", stdin);
  43. nhap();
  44. cout<<th1r<<endl;
  45. cout<<th2r;
  46. return 0;
  47. }
  48. /*
  49. inp: a1b10
  50.   b3c9b4
  51. out: 7
  52.   4
  53. */
Success #stdin #stdout 0.01s 5436KB
stdin
a1b10
b3c9b4
stdout
7
4