-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.cpp
More file actions
33 lines (30 loc) · 630 Bytes
/
A.cpp
File metadata and controls
33 lines (30 loc) · 630 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<iostream>
#include<stdio.h>
using namespace std;
#define lli long long int
int main(){
string s;
cin>>s;
int siz = s.size();
int in = 0;
int d1;
int d2;
int mn;
int tot = 0;
for(int i=0;i<siz;i++){
int now = s[i] - 'a';
if(now>in){
d1 = now - in;
d2 = (26-now) + in;
}
else{
d1 = in - now;
d2 = (26 - in) + now;
}
mn = min(d1,d2);
in = s[i] - 'a';
//cout<<mn<<endl;
tot = tot +mn;
}
cout<<tot<<endl;
}