Advertisement
Saleh127

Untitled

Apr 22nd, 2020
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. long long int a,b,c,d=0,e=0,f,i,j,k,l;
  6. cin>>a>>b;
  7. for(i=0;i<b;i++)
  8. {
  9. cin>>c;
  10. if(c>=d)
  11. {
  12. e+=(c-d);
  13. }
  14. else
  15. {
  16. e+=(a+c-d);
  17. }
  18. d=c;
  19. }
  20. cout<<e-1<<endl;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement