Skip to content

Instantly share code, notes, and snippets.

@ik11235
Created June 27, 2015 14:26
Show Gist options
  • Select an option

  • Save ik11235/994bec4e1eaac45639e5 to your computer and use it in GitHub Desktop.

Select an option

Save ik11235/994bec4e1eaac45639e5 to your computer and use it in GitHub Desktop.
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
int n,a,b;
cin>>n>>a>>b;
int now=0;
for (int i=0; i < n; i++) {
string s;
int d;
cin>>s;
cin>>d;
if(d<a)
d=a;
else if(d>b)
d=b;
if(s=="East")
{
now+=d;
}
else
{
now-=d;
}
}
if(now>0)
cout<<"East "<<now<<endl;
else if(now<0)
cout<<"West "<<-now<<endl;
else
cout<<0<<endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment