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