Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include<cmath>
  3. using namespace std;
  4. int main() {
  5. int n;
  6. string s;
  7. double k,m,l=30,l1=4000;
  8. cin >> n;
  9. cin >> k;
  10. for(int i=0;i<n;i++){
  11.  
  12. cin >> m >> s;
  13. if ( (k>m && s=="closer") ||( k<m && s=="further")){
  14. if ((abs(k-m))/2<l1){
  15. l1=(abs(k-m))/2;
  16. }
  17. }
  18. else{
  19. if ((k+m)/2>l){
  20. l=(k+m)/2;
  21. }
  22. }
  23. k=m;
  24. }
  25. cout << l1<< ' ' << l;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement