Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

Codeforces Round #376 (Div. 2), problem: (A) Night at the Museum

#include<iostream>
#include<cmath>
using namespace std;
#include<cstring>

int main()
{
	int sum = 0;
	char ch[100];
	cin >> ch;
	char begin = 'a';
	for (int i = 0; i <strlen(ch); i++)
	{
		int l1 = abs(ch[i] - begin);
		int l2 = 26 - abs(l1);
		sum += min(l1, l2);
		begin = ch[i];
	}
	cout << sum << endl;
	return 0;
}
Source by codejudge.blogspot.com #
 
PREVIOUS NEXT
Tagged: #Codeforces #Round #Night #Museum
ADD COMMENT
Topic
Name
8+4 =