Last active
December 13, 2015 17:58
-
-
Save rohith2506/4951254 to your computer and use it in GitHub Desktop.
Topcoder 570-div2 medium problem solution:-
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 <iostream> | |
#include <stdio.h> | |
#include <vector> | |
#include <set> | |
#include <algorithm> | |
using namespace std; | |
class Robertherb{ | |
public: | |
int getmax(int t,vector<int> a){ | |
int x=0,y=0; | |
int dir=0; | |
for(int i=0;i<t;i++){ | |
for(int j=0;j<a.size();j++){ | |
if(dir==0) | |
y+=a[j]; | |
else if(dir==1) | |
x+=a[j]; | |
else if(dir==2) | |
y-=a[j]; | |
else if(dir==3) | |
x-=a[j]; | |
else{} | |
dir=(dir+a[j])%4; | |
} | |
} | |
return (Math.abs(x)+Math.abs(y)); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment