Monday, September 16, 2019

Codeforce A. Middle of the Contest

  1. #include< bits/stdc++.h >
  2. using namespace std;
  3. int main(){
  4. int h1, m1, h2, m2, ans = 0, resH = 0, resM = 0, rM;
  5. scanf("%d:%d", &h1, &m1);
  6. scanf("%d:%d", &h2, &m2);
  7. if(m1 > m2) ans = (60 - m1) + m2;
  8. else ans = (h2 - h1)*60 + (m2-m1);
  9. ans /= 2;
  10. resH = h1 + ans/60;
  11. rM = m1 + ans%60;
  12. if( rM / 60 > 0) resH += rM / 60;
  13. resM = rM%60;
  14. if(resH < 10) cout <<0;
  15. cout << resH << ":";
  16. if(resM < 10) cout << 0;
  17. cout << resM << endl;
  18. return 0;
  19. }

No comments: