Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- const int MX=2e5+3;
- int n;//k,t=0;
- int lat=0,longt=0;
- int main()
- {
- cin>>n;
- for(int i=0;i<n;i++)
- {
- int a;
- string b;
- cin>>a>>b;
- if(longt==0)
- {
- if(b!="South")
- {
- cout<<"NO";
- return 0;
- }
- }if(longt==20000)
- {
- if(b!="North")
- {
- cout<<"NO";
- return 0;
- }
- }
- if(b=="South")longt+=a;
- if(b=="North")longt-=a;
- if(longt<0||longt>20000)
- {
- cout<<"NO";
- return 0;
- }
- }
- //cout<<lat<<' '<<longt<<'$';
- if(longt==0)
- {
- cout<<"YES";
- }
- else cout<<"NO";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement