Created
June 27, 2015 14:26
-
-
Save ik11235/994bec4e1eaac45639e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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