https://www.codechef.com/problems/ROTATION/

https://www.codechef.com/problems/ROTATION/

this is my approach i am getting WA , please Help!!

n,m=map(int,raw_input().split())
a=list(map(int,raw_input().split()))
current=0
for _ in range(m):
s=raw_input()
if s[0]==“A”:
current=current-int(s[2])
elif s[0]==“C”:
current+=int(s[2])
else:
if current>0:
print a[ (int(s[2]) - 1 + n - current) % n ]
elif current<0:
print a[ (int(s[2]) - 1 + current) % n ]
else:
print a[int(s[2]) - 1]

1 Like