Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- string s;
- cin>>s;
- int sum=0;
- int temp='a';
- for(int i=0;i<s.length();i++){
- if((int)s[i]> temp){
- sum+=min(abs(temp-s[i]),temp+26-s[i]);
- }else
- sum+=min(temp-s[i],s[i]+26-temp);
- temp=s[i];
- }
- cout<<sum<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement